Skip to content

feat: always break after linebreak syntax and preserve linebreak in more cases in text-wrapping#286

Merged
QuadnucYard merged 1 commit intotypstyle-rs:masterfrom
QuadnucYard:reflow-linebreak
May 15, 2025
Merged

feat: always break after linebreak syntax and preserve linebreak in more cases in text-wrapping#286
QuadnucYard merged 1 commit intotypstyle-rs:masterfrom
QuadnucYard:reflow-linebreak

Conversation

@QuadnucYard
Copy link
Copy Markdown
Collaborator

@QuadnucYard QuadnucYard commented May 13, 2025

Closes #285.

When text-wrapping is enabled:

  • Always break after \, except that there is a marker-like character after.
  • Preserve linebreak after:
    matches!(SyntaxKind::LineComment
        | SyntaxKind::BlockComment
        | SyntaxKind::Linebreak
        | SyntaxKind::Label
        | SyntaxKind::CodeBlock
        | SyntaxKind::ContentBlock
        | SyntaxKind::Conditional
        | SyntaxKind::WhileLoop
        | SyntaxKind::ForLoop
        | SyntaxKind::Contextual
    ) || is_block_equation(node)
      || is_block_raw(node)

Also fixed a bug discovered in development:

  • Trailing parbreaks in the content block are missing in text-wrapping.

Tell me if more cases should be covered.

@github-actions
Copy link
Copy Markdown

github-actions bot commented May 13, 2025

📊 Benchmark Performance Report

group                        base                                   pr
-----                        ----                                   --
pretty-cetz-manual           1.00    947.9±6.53µs        ? ?/sec    1.02    963.2±5.61µs        ? ?/sec
pretty-codly                 1.00  1976.0±11.09µs        ? ?/sec    1.02      2.0±0.12ms        ? ?/sec
pretty-cpe                   1.00     13.1±0.15ms        ? ?/sec    1.00     13.0±0.15ms        ? ?/sec
pretty-fletcher-diagram      1.00    560.7±8.29µs        ? ?/sec    1.02    571.3±7.22µs        ? ?/sec
pretty-fletcher-draw         1.00  1374.2±12.09µs        ? ?/sec    1.01  1385.3±10.94µs        ? ?/sec
pretty-tablex                1.00      3.7±0.03ms        ? ?/sec    1.01      3.7±0.01ms        ? ?/sec
pretty-touying-core          1.00      2.4±0.02ms        ? ?/sec    1.04      2.4±0.09ms        ? ?/sec
pretty-touying-utils         1.00  1324.0±28.71µs        ? ?/sec    1.01  1333.8±11.05µs        ? ?/sec
pretty-undergraduate-math    1.00  1032.4±42.78µs        ? ?/sec    1.00   1030.3±8.78µs        ? ?/sec

Generated by GitHub Actions on Wed May 14 16:14:26 UTC 2025

@QuadnucYard QuadnucYard force-pushed the reflow-linebreak branch 7 times, most recently from 81fb11e to fe3cd7a Compare May 13, 2025 11:57
@QuadnucYard QuadnucYard merged commit 15fe8bc into typstyle-rs:master May 15, 2025
15 checks passed
@QuadnucYard QuadnucYard deleted the reflow-linebreak branch May 15, 2025 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Markup linebreak (\) is ignored with --wrap-text

2 participants