You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I'm building a math formater for markdown documents and I found this cool project!
I use remark-math to extract math blocks from the document, then format it using unified-latex-prettier. It works flawlessly and the output generally looks good to me.
But there is one case where the output seems weird. By default, 'printWidth' is 80. But I found that sometimes it produces outputs far longer than 80 columns. And this is one example.
I inspect on the code and the generated prettier doc. And I found that line breaks are only feasible at the end of the line. Therefore, prettier is unable to further break this long line.
This may because the code simply print the node when the type is string.
I think this can be enhanced by introducing more line breaks. For example, soft line breaks can be added before \left, after \right and around +, =, -. We can also add softline breaks at the end of any macro.
The text was updated successfully, but these errors were encountered:
@Enter-tainer I'm glad you're finding the project useful!
I think the barrier is not technical. Rather, it is how aligned environments should look. At the moment, aligned environments are forced to align via the & marks, regardless of whether this fits within the character wrapping. I'm honestly not sure what the best behavior is here.
One possible alternative is to break and indent at each & if the line goes too far. Something like
That still causes long lines though... Your suggestion of breaking at \left and \right is a nice idea. It definitely works if the content that is too long is in the last column. When it's in the middle column or the first column, I worry about the readability.
A PR for this would be welcome :-D (Maybe you can add a print option like, --wrapAlignEnvironments ?)
Also, feel free to generate some proposals/examples for line breaking in align/tabular environments.
Hi! I'm building a math formater for markdown documents and I found this cool project!
I use remark-math to extract math blocks from the document, then format it using unified-latex-prettier. It works flawlessly and the output generally looks good to me.
But there is one case where the output seems weird. By default, 'printWidth' is 80. But I found that sometimes it produces outputs far longer than 80 columns. And this is one example.
I inspect on the code and the generated prettier doc. And I found that line breaks are only feasible at the end of the line. Therefore, prettier is unable to further break this long line.
This may because the code simply print the node when the type is
string
.I think this can be enhanced by introducing more line breaks. For example, soft line breaks can be added before
\left
, after\right
and around+
,=
,-
. We can also add softline breaks at the end of any macro.The text was updated successfully, but these errors were encountered: