Add suport for line comments

This also switches comments to produce the same AST whether it is
an inline comment or a line comment.
This commit is contained in:
Kevin Brown 2020-05-08 18:21:40 -04:00 committed by Kevin
parent 5799223303
commit bcf99099b6
2 changed files with 22 additions and 4 deletions

View File

@ -17,6 +17,7 @@ expression
| line_block_expression
| variable_expression
| comment_expression
| line_comment_expression
;
raw_block_expression
@ -229,7 +230,7 @@ filter_parameters
comment_expression
=
comment_open comment_content comment_close
comment_open comment:comment_content comment_close
;
comment_open
@ -247,6 +248,21 @@ comment_content
{ !comment_close CHAR }*
;
line_comment_expression
=
line_comment_open comment:line_comment_content &"\n"
;
line_comment_open
=
"## "
;
line_comment_content
=
{ !"\n" CHAR } *
;
content
=
!(
@ -254,6 +270,7 @@ content
| block_open
| variable_open
| comment_open
| line_comment_open
) CHAR ;
LITERAL

View File

@ -35,9 +35,10 @@ across lines #}
<textarea name="{{ name }}" rows="{{ rows }}" cols="{{ cols
}}">{{ value|e }}</textarea>
{% endmacro %}
{# comment contents
across lines #}
<ul>
# for href, caption in [('index.html', 'Index'),
('about.html', 'About')]:
<li><a href="{{ href }}">{{ caption }}</a></li>
# for item in seq:
<li>{{ item }}</li> ## this comment is ignored
# endfor
</ul>