Skip to content

Customizing source line break behavior #710

@Erithax

Description

@Erithax

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature or requestsyntaxAbout syntax, parsing, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions