Markup Formatting
List indentation is automatically corrected and standardized:
Example
Before
- Fruit - Apple - Banana- Vegetable - Carrot - Tomato
- Fruit - Apple - Banana- Vegetable - Carrot - Tomato
After
- Fruit - Apple - Banana- Vegetable - Carrot - Tomato
- Fruit - Apple - Banana- Vegetable - Carrot - Tomato
Lists within content blocks are properly formatted with surrounding linebreaks:
Example
Before
#{ [- single] [- indented - less ] [- indented - same - then less - then same ] [- indented - more - then same - then less ]}
#{ [- single] [- indented - less ] [- indented - same - then less - then same ] [- indented - more - then same - then less ]}
After
#{ [- single] [ - indented - less ] [ - indented - same - then less - then same ] [ - indented - more - then same - then less ]}
#{ [- single] [ - indented - less ] [ - indented - same - then less - then same ] [ - indented - more - then same - then less ]}
When text wrapping is enabled with --wrap-text--wrap-text, typstyle intelligently wraps long lines while preserving important formatting and semantic structure:
Example wrap_text: true, max_width: 30
Before
Let's say you have a long text that needs to be wrapped in the markup. This is a very long sentence.
Let's say you have a long text that needs to be wrapped in the markup. This is a very long sentence.
After
Let's say you have a long textthat needs to be wrapped inthe markup. This is a verylong sentence.
Let's say you have a long textthat needs to be wrapped inthe markup. This is a verylong sentence.
typstyle applies specific wrapping logic based on node types:
- Cannot break before: Markup markers (
==,++,--,//) and labels to prevent misinterpretation - Force hard breaks: Around block equations to keep them on exclusive lines
- Preserve breaks after: Block elements, line comments, and structural nodes (code blocks, conditionals, loops)
- Exclusive lines: Single non-text nodes or hash-prefixed expressions (e.g.,
#figure()#figure()) - Soft breaks: Regular spaces become flexible break points unless restricted by above rules
Example wrap_text: true, max_width: 30
Before
Some pieces should be exclusion except $"inline equation"$ and `raw`:- This is a list$ "block equation" $#figure([Figures])#figure([Labeled figures]) <label>That's all! Wait, a linebreak \should be \ kept at the end\ of the line. \But \ / never \ = break \ + before \ - markers#[Never \ / Give \ = You \ + Up \]#([Man!\ ], [\ What\ can\ I\ say\ ?])#let fig = (..) => []#fig("image1")[Caption] <label1>#fig("image2")[Caption] <label2>This is a code block: #{ // code block!}I don't want to eat the linebreak.A blocky node should not stick #[]the content after it.Not #if true { }Not #while false { }Not #for i in range(5) {}Not #context 1And block equations: $ eq $Andalso ``` block raw ```but not ``` non-block raw ```End...
Some pieces should be exclusion except $"inline equation"$ and `raw`:- This is a list$ "block equation" $#figure([Figures])#figure([Labeled figures]) <label>That's all! Wait, a linebreak \should be \ kept at the end\ of the line. \But \ / never \ = break \ + before \ - markers#[Never \ / Give \ = You \ + Up \]#([Man!\ ], [\ What\ can\ I\ say\ ?])#let fig = (..) => []#fig("image1")[Caption] <label1>#fig("image2")[Caption] <label2>This is a code block: #{ // code block!}I don't want to eat the linebreak.A blocky node should not stick #[]the content after it.Not #if true { }Not #while false { }Not #for i in range(5) {}Not #context 1And block equations: $ eq $Andalso ``` block raw ```but not ``` non-block raw ```End...
After
Some pieces should beexclusion except$"inline equation"$ and `raw`:- This is a list$ "block equation" $#figure([Figures])#figure([Labeled figures]) <label>That's all! Wait, a linebreak\should be \ kept at the end \of the line. \But \ / never \ = break \ +before \ - markers#[Never \ / Give \ = You \ + Up \]#( [Man!\ ], [\ What\ can\ I\ say\ ?],)#let fig = (..) => []#fig( "image1",)[Caption] <label1>#fig( "image2",)[Caption] <label2>This is a code block: #{ // code block!}I don't want to eat thelinebreak. A blocky nodeshould not stick #[]the content after it. Not#if true {}Not #while false {}Not #for i in range(5) {}Not #context 1And block equations:$ eq $And also``` blockraw ```but not ``` non-block raw ```End...
Some pieces should beexclusion except$"inline equation"$ and `raw`:- This is a list$ "block equation" $#figure([Figures])#figure([Labeled figures]) <label>That's all! Wait, a linebreak\should be \ kept at the end \of the line. \But \ / never \ = break \ +before \ - markers#[Never \ / Give \ = You \ + Up \]#( [Man!\ ], [\ What\ can\ I\ say\ ?],)#let fig = (..) => []#fig( "image1",)[Caption] <label1>#fig( "image2",)[Caption] <label2>This is a code block: #{ // code block!}I don't want to eat thelinebreak. A blocky nodeshould not stick #[]the content after it. Not#if true {}Not #while false {}Not #for i in range(5) {}Not #context 1And block equations:$ eq $And also``` blockraw ```but not ``` non-block raw ```End...
typstyle measures Unicode width and will not break between words if no space exists in the original text.
Example wrap_text: true, max_width: 40
Before
这是一个中文段落,包含链接 https://typst.app/ 和*强调文本*。続いて`コード要素`と https://docs.typst.app/ を含む日本語の段落です。Mixed CJK and Latin: Visit 访问 https://example.com/文档 for documentation.한글과 URL: https://한글.kr/ contains Korean text mixed with $alpha + beta$.Multiple scripts: أهلاً بك في *타이프스트* เอกสาร with `inline code`.
这是一个中文段落,包含链接 https://typst.app/ 和*强调文本*。続いて`コード要素`と https://docs.typst.app/ を含む日本語の段落です。Mixed CJK and Latin: Visit 访问 https://example.com/文档 for documentation.한글과 URL: https://한글.kr/ contains Korean text mixed with $alpha + beta$.Multiple scripts: أهلاً بك في *타이프스트* เอกสาร with `inline code`.
After
这是一个中文段落,包含链接https://typst.app/ 和*强调文本*。続いて`コード要素`とhttps://docs.typst.app/を含む日本語の段落です。Mixed CJK and Latin: Visit 访问https://example.com/文档 fordocumentation. 한글과 URL:https://한글.kr/ contains Korean textmixed with $alpha + beta$.Multiple scripts: أهلاً بك في *타이프스트*เอกสาร with `inline code`.
这是一个中文段落,包含链接https://typst.app/ 和*强调文本*。続いて`コード要素`とhttps://docs.typst.app/を含む日本語の段落です。Mixed CJK and Latin: Visit 访问https://example.com/文档 fordocumentation. 한글과 URL:https://한글.kr/ contains Korean textmixed with $alpha + beta$.Multiple scripts: أهلاً بك في *타이프스트*เอกสาร with `inline code`.