Closed arnaudgolfouse closed 11 months ago
Thanks a lot for your bug report! I suspect this might be a weird Typst parser behavior
String literals in code mode also seems to be changed as well as in math mode.
$ typstfmt --version
version: 0.2.6 (6974e5d9)
$ cat input.typ
#raw(" foo")
$ cat input.typ | typstfmt
#raw(" foo")
As far as I can tell from my investigation of the above example, the Typst parser is working, and the subsequent format_default
function seems to be removing the adjacent whitespace.
[lib/src/lib.rs:40] parse(s) = Markup: 16 [
Hashtag: "#",
FuncCall: 14 [
Ident: "raw",
Args: 11 [
LeftParen: "(",
Str: "\" foo\"",
RightParen: ")",
],
],
Space: "\n",
]
if node.kind()
is Str literal, it should be given special treatment in formatting.
True, I talked a bit fast, the solution would be to add string literals to the no_format rule (just like raw blocks)
I can try to do it soonish but it's really difficult for me to do that right now so I really appreciate PR
Typstfmt version
version: 0.2.6 (b45cab03)
Description
Whitespace is compressed when using a string in math mode, but it should not.
Before
After
I don't really know if this is intended behaviour from typst, but it is handy 🙂