diff --git a/grammar.js b/grammar.js index bae7948..12e84e0 100644 --- a/grammar.js +++ b/grammar.js @@ -603,7 +603,7 @@ const django = grammar({ endTagOpen: ($) => seq("{%", $._group_open_tag_read, optional(SEP)), endTagClose: ($) => seq(optional($.unexpected_argument), $._group_close, optional(SEP), "%}"), - content: ($) => /(?:[^\{]|\{[^\{#%}])+/, + content: ($) => /(?:[^\{]|\{[^\{#%])+/, // the separator between the parts of a tag; see SEP _sep: ($) => /[ \t\r\n]+/, template_node: ($) => diff --git a/src/grammar.json b/src/grammar.json index 1c14beb..59baf1a 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -327,7 +327,7 @@ }, "content": { "type": "PATTERN", - "value": "(?:[^\\{]|\\{[^\\{#%}])+" + "value": "(?:[^\\{]|\\{[^\\{#%])+" }, "_sep": { "type": "PATTERN", diff --git a/src/parser.c b/src/parser.c index 88877ba..a1b3e9a 100644 --- a/src/parser.c +++ b/src/parser.c @@ -8211,8 +8211,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead == '#') ADVANCE(53); if (lookahead == '%') ADVANCE(26); if (lookahead == '{') ADVANCE(51); - if (lookahead != 0 && - lookahead != '}') ADVANCE(28); + if (lookahead != 0) ADVANCE(28); END_STATE(); case 7: if (lookahead == '%') ADVANCE(17); @@ -8303,8 +8302,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { if (lookahead != 0 && lookahead != '#' && lookahead != '%' && - lookahead != '{' && - lookahead != '}') ADVANCE(28); + lookahead != '{') ADVANCE(28); END_STATE(); case 21: if (lookahead != 0 && diff --git a/test/corpus/template_variable.txt b/test/corpus/template_variable.txt index 619f5b9..0b73102 100644 --- a/test/corpus/template_variable.txt +++ b/test/corpus/template_variable.txt @@ -211,6 +211,7 @@ Template Variable Literal Adjacent To Name --- + ================== Template Variable With Escaped String ================== @@ -272,6 +273,7 @@ Template Variable Attribute Beginning With Underscore --- + ================== Template Variable Translated String ================== @@ -320,6 +322,7 @@ Template Variable Translated String With Spaces --- + ================== Template Variable Spanning Lines ================== @@ -462,6 +465,7 @@ Template Variable Attribute Of A Literal --- + ================== Template Variable Trailing Dot With An Exponent ================== @@ -489,6 +493,7 @@ Template Variable Trailing Dot --- + ================== Template Variable Signed Trailing Dot :error @@ -498,3 +503,27 @@ Template Variable Signed Trailing Dot --- + + +================== +Braces That Open Nothing Are Text +================== + +{% if x %}Hello {} world{% endif %} + +--- + +(template + (content) + (if_group + (if_block + (if_tag + (predicate + (filtered_value + (value + (variable_attribute + (identifier)))))) + (template + (content))) + (endif_tag)) + (content))