-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Customizing source line break behavior #710
Copy link
Copy link
Open
Labels
feature requestNew feature or requestNew feature or requestsyntaxAbout syntax, parsing, etc.About syntax, parsing, etc.
Description
I don't know if this is possible and if there is demand but:
Current line breaking behavior
| source | compiled |
|---|---|
| \n | [ ] |
| \ | linebreak() |
| >1 times \n | parbreak() |
Want to be able to customize it to
| source | compiled |
|---|---|
| \n | linebreak() |
| > 1 times \n | parbreak() |
| \\n | continue line |
or maybe even
| source | compiled |
|---|---|
| \n | [ ] |
| \n\n | linebreak() |
| >2 times \n | parbreak() |
| \ | linebreak() |
Bonus if this behavior can be changed depending on the context (e.g. in a paragraph vs table cell) and if rules for trimming line breaks in certain contexts can be defined.
Doing this in Typst code right now is almost impossible, mostly because
- show rules like
#show regex("\\s"): white_char => ...never capture line breaks in the source - \n gets compiled to [ ] (making it indistinguishable from many other things that generate [ ])
- the content tree is currently not well traverseable and mutable.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature requestNew feature or requestNew feature or requestsyntaxAbout syntax, parsing, etc.About syntax, parsing, etc.