Replies: 1 comment 2 replies
-
Just noticed I have forgotten to provide my topiary queries: [
"{{"
"{%"
"{#"
] @append_space
[
"}}"
"%}"
"#}"
] @prepend_space
[
"+"
"-"
"~"
"%"
"*"
"/"
"|"
"=="
"!="
"<"
">"
">="
"<="
"if"
"elif"
"else"
"endif"
"for"
"endfor"
"include"
"import"
"as"
"extends"
"in"
"and"
"or"
"not"
"is"
"break"
"continue"
"set"
"set_global"
"filter"
"endfilter"
"block"
"endblock"
"macro"
"endmacro"
"raw"
"endraw"
] @prepend_space @append_space
(assignment_expression "=" @prepend_space @append_space)
; Remove trailing comma from last element of single line array.
(array
("," @delete . "]")(#single_line_only!)
)
("," @append_spaced_softline) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to write a formatter for Topiary, or using Topiary, for a templating language - Tera. I've written the following Tree-sitter grammar for the language: https://github.com/uncenter/tree-sitter-tera.
Tera templating logic is contained within "tags" and the external content (which is ignored by the language, arbitrary text) is marked under the
content
node. A content node usually has non-whitespace characters but could contain just spaces and newlines between tags, such as:I would like Topiary to completely ignore whitespace contained within
content
nodes, but it appears to be stripping it.The example above:
is formatted to:
(Why the contents of the comments are being removed is another question entirely.)
Is this possible to solve? What do you suggest?
Beta Was this translation helpful? Give feedback.
All reactions