Skip to content

fix: currency symbols stick to adjacent numbers during line breaking#105

Open
ImpulseB23 wants to merge 2 commits intochenglou:mainfrom
ImpulseB23:fix/currency-symbol-wrapping
Open

fix: currency symbols stick to adjacent numbers during line breaking#105
ImpulseB23 wants to merge 2 commits intochenglou:mainfrom
ImpulseB23:fix/currency-symbol-wrapping

Conversation

@ImpulseB23
Copy link
Copy Markdown

Fixes #98

Currency symbols ($, £, , ¥, etc.) were getting segmented separately from adjacent text by Intl.Segmenter, leaving a breakable gap. So pretext could wrap between $ and 500, or between 500 and , which browsers don't do.

Added a \p{Sc} (Unicode currency symbol category) check to both the forward-sticky and left-sticky merge passes in analysis.ts. This covers prefix ($500) and postfix (500€) currencies, matching browser behavior.

Before:

  • $500 -> segments ["$", "500"] (breakable)
  • 500€ -> segments ["500", "€"] (breakable)

After:

  • $500 -> segments ["$500"]
  • 500€ -> segments ["500€"]

Tested in Chromium on Windows across $, £, , ¥, at various widths. All match browser line counts. 81/81 existing tests pass.

Copilot AI review requested due to automatic review settings April 5, 2026 15:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes incorrect line-break opportunities introduced by Intl.Segmenter splitting currency symbols away from adjacent text, bringing Pretext wrapping behavior in line with browser layout.

Changes:

  • Add a Unicode currency-symbol (\p{Sc}) detector in analysis.ts.
  • Treat currency symbols as both left-sticky and forward-sticky merge candidates so $500 / 500€ are kept as single segments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Wrapping of "$___" is inconsistent with browser

2 participants