typstfmt
typstfmt copied to clipboard
[bug] Text wrapping: broken list case; 2x indent; length overflow
This is a separate issue, related to the #74, since the text wrapping itself kinda works. Now it's time for bugs!
Before:
We have next things:
- thing 1;
- thing 2;
- thing 3.
#f[Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim aeque doleamus animo, cum corpore dolemus, fieri.]
With default:
indent_space = 2
max_line_length = 50
experimental_args_breaking_consecutive = false
And version: 0.2.0#578fabc
After 1st run:
We have next things: - thing 1;
- thing 2;
- thing 3.
#f[Lorem ipsum dolor sit amet, consectetur adipiscing
elit, sed do eiusmod tempor incididunt ut labore
et dolore magnam aliquam quaerat voluptatem. Ut
enim aeque doleamus animo, cum corpore dolemus,
fieri.]
After 2nd run:
We have next things: - thing 1; - thing 2;
- thing 3.
#f[Lorem ipsum dolor sit amet, consectetur adipiscing
elit, sed do eiusmod tempor incididunt ut labore
et dolore magnam aliquam quaerat voluptatem. Ut
enim aeque doleamus animo, cum corpore dolemus,
fieri.]
After 3rd run:
We have next things: - thing 1; - thing 2; - thing 3.
#f[Lorem ipsum dolor sit amet, consectetur adipiscing
elit, sed do eiusmod tempor incididunt ut labore
et dolore magnam aliquam quaerat voluptatem. Ut
enim aeque doleamus animo, cum corpore dolemus,
fieri.]
After 4th run:
We have next things: - thing 1; - thing 2; - thing
3.
#f[Lorem ipsum dolor sit amet, consectetur adipiscing
elit, sed do eiusmod tempor incididunt ut labore
et dolore magnam aliquam quaerat voluptatem. Ut
enim aeque doleamus animo, cum corpore dolemus,
fieri.]
Next run will be as in 3rd, after as in 4th and so on.
But with max_line_length = 80
it stops formatting after 3rd run.
Note that the text lines exceed the 50
mark, which is also wrong (same with 80
).
What's wrong:
- [x] merge of
list
lines with non-list
lines if they are on adjacent lines (it could be/
/-
/+
/\d+\.
)- [x] in
0.2.1#1817538
version-
/+
/\d+\.
are fixed - [x] in #83
/
(terms) also got fixed
- [x] in
- [x]
it takes 2 runs to add 2 indents to the content block with a text (which is a function argument) — fixed at least in0.2.1#1817538
- [ ] it adds 2 indents to the
content
block with a text (which is a function argument) - [ ] some lines of text can exceed the limit from the config (file) — discussed in #86
How it supposed to look like:
We have next things:
- thing 1;
- thing 2;
- thing 3.
#f[Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magnam aliquam
quaerat voluptatem. Ut enim aeque doleamus
animo, cum corpore dolemus, fieri.]
But since the function name could be very long, it should format like this (either only for long function names or for all cases):
We have next things:
- thing 1;
- thing 2;
- thing 3.
#very-long-long-long-long-long-function-name(
[Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magnam aliquam
quaerat voluptatem. Ut enim aeque doleamus
animo, cum corpore dolemus, fieri.]
)
This last one can be debatable, I assume, but the main problem, is that Typst right now can't do something like this (shell):
var="\
first line
secondline"
Typst instead of one additional space will add a new paragraph if \
is used right after [
(same with ]
). So, to line up all the content
block lines, we can use otherwise redundant ()
to wrap the content
block.
Note that if the function name is very long, it could exceed the max line limit, but we can't do anything about it (we can't cut it in half).