Closed Ciantic closed 6 years ago
Thanks for pointing me to that plugin and this issue.
... 'And the formatters don't care about $content$ environment, and they probably shouldn't care' ...
hmm ... If I was writing a formatter I would like to know the structure of the source to format very well ... I won't expect the source code writer to consider other rules than the grammar of the source code. I would decide to make my formatter extensible for support of yet unknown grammars ...
Your proposal won't work. markdown-it is requested by mdmath to deliver $...$
as inline content .. so would not be recognised with embedded newline.
Please raise an Issue at prettier.
Thanks again ...
I'm using prettier to re-format a markdown document as I save.
Suppose you have a:
And the formatters don't care about $content$ environment, and they probably shouldn't care, since markdown should ignore singular new lines.
And they re-format it like this:
The math mode breaks itself because there is a newline middle of it.
There is a couple of fixes I can think of:
Make markdown-it-texmath to remove newlines in inline $content$ env before passing it to KaTex or elsewhere, and probably leave $$content$$ as is, fixing everything is not required here.
Fix prettier to treat $content$ as non-wrappable (unlikely to happen).
P.S. I probably try to create issue in Prettier repo too, since math is probably one of most used extensions of markdown. Maybe they will do something to it so that it won't break it.
Especially $$content$$ can't be fixed in this fine plugin of yours, because it can't be made newline aware.