Open cionx opened 3 years ago
Sorry for the long response time. Adding \text
is straightforward but parsing \intertext
correctly with all its quirks can be quite challenging if not almost impossible without some severe modifications to the grammar. Honestly, I am not sure how to parse the last example correctly, as this does not really fit into a tree.
I think having just the "standard" use parsed correctly would be great already. The last example should be very rare and would be acceptable not to support (for the foreseeable future). Especially \text{}
is something that is frequently used.
I think having just the "standard" use parsed correctly would be great already. The last example should be very rare and would be acceptable not to support (for the foreseeable future). Especially \text{} is something that is frequently used.
5686c9c adds a new rule with support for the simple cases. The hard case is probably a "wont' fix" for now.
From the issue https://github.com/nvim-treesitter/nvim-treesitter/issues/2214 both \text
and \intertext
are supported, only missing one is \shortintertext
I don't understand why, though, the grammar looks fine:
text_mode: $ =>
seq(
field('command', choice('\\text', '\\intertext', '\\shortintertext')),
field('content', $.curly_group),
),
The current grammar doesn’t seem to know the command
\text
,\intertext
, and\shortintertext
provided byamsmath
andmathtools
.\text{}
can be used in math mode (both inline and display) to temporarily enter text mode. A typical application may look as follows:\intertext{}
functions similarly, but can only be used in multi-line display environments (e.g.align*
). This command will exit math mode, insert the given text, and then reenter math mode.\shortintertex{}
is a variant of\intertext{}
with different spacing. There should be no difference in terms of function/parsing.I’m not sure how
\(short)intertext
ought to be parsed: In terms of code it is a child of the surrounding math environment (e.g.align*
). But it can actually contains content that (I think) would not fit in the resulting tree structure.For example: the following is a valid (and useful) use of
\intertext
: