astrale-sharp / typstfmt

Apache License 2.0
252 stars 25 forks source link

Line wrapping before number at end of sentence incorrectly creates numbered list #164

Open martin-walls opened 5 months ago

martin-walls commented 5 months ago

Describe the bug When a sentence ends with a number immediately before the period, this can get wrapped onto a new line. This happens when the number is exactly at the line length limit. When this happens, the Typst compiler interprets it as the start of a numbered list, and therefore the output for the rest of the paragraph is incorrect.

To Reproduce Minimal example:

This is a paragraph containing a line that happens to end in a number, which is 4. Typstfmt does not format this correctly.

With the default settings, Typstfmt formats this as

This is a paragraph containing a line that happens to end in a number, which is
4. Typstfmt does not format this correctly.

Expected output: good

Actual output: bad

astrale-sharp commented 5 months ago

Hey there! Oh that's a problem alright, we're possibly going to need logic that checks if breaking the line at a point starts a new line with a number, - or similar ast breaking characters.

In the meantime I would advise disabling line breaking