Closed bengolds closed 2 years ago
(note -- this isn't urgent, since we can work around this by replacing multiple spaces with one)
This is a little tricky...
Before being parsed, the LaTeX string goes through a tokenization phase, during which consecutive spaces are collapsed into one, comments % foo
are removed, and multiple lines are merged into one. By the time parsing begins, that info is gone...
Would you expect the comment and new lines to be preserved as well? And if so, what should they be attached to?
Hmmm... actually, there are other primitive commands that need to be handled during the tokenization phase ("the gullet" in TeX parlance), such as \bgroup
, \obeyspaces
, \relax
and a bunch more. These also are not currently round-tripped...
I need to think about this.
This is definitely a strange one; my expectation would be:
latex
value attached to the top level is exactly what was passed to parse
, comments, spaces, and al.latex
value of the component nodes could have comments/spacing/anything else modified or stripped.Or, perhaps there's a distinction here between the parser returning "normalized LaTeX" and the "original LaTeX".
ah, ok, then if only the top-level is "verbatim", that is easy...
That'd be my expectation -- does that seem reasonable to you?
it would have to be a judgement call as to where to assign the spaces/comments for any child nodes anyway.
Version 0.44
Steps to reproduce
jsonSerializationOptions.metadata = ['latex']
parse('1 + x')
)What I'd expect I'd expect the
latex
field to exactly match the input, including all of the spaces in the original expression; ie:{fn: ["Add", {num: "1", latex: "1"}, "x"], latex: "1 + x"}
What happens instead Multiple contiguous spaces are collapsed into one:
{fn: ["Add", {num: "1", latex: "1"}, "x"], latex: "1 + x"}