prepareWithSegments()no longer returnssegLevels. Those approximate bidi levels per segment couldn't produce visual order, and computing them slowed everyprepareWithSegments()and rich-inline preparation, most for Arabic and Hebrew text. To draw mixed bidi text, render each paragraph as one DOM element with its direction set, and the browser orders every line. Lines drawn separately, such as with CanvasfillText(), are each ordered as their own paragraph, so numbers or punctuation next to a line break can come out in a different order (#258).
- Narrow wrapping around invisible controls and combining marks now more closely matches desktop Chrome and Firefox.
- Paragraphs made only of zero-width spaces now occupy one line instead of disappearing (#223).
- A zero-width space at the start of a paragraph or after a hard line break no longer disappears when the following text wraps to the next line (#227).
- Lines can now break after
?, and after!or other exclamation punctuation such as؟and۔, before a following word, as browsers do, including after a space or zero-width space. Chrome and Safari still keep!with a following ASCII letter or digit; Firefox breaks there too (#228). - In Safari, a combining mark after a zero-width space at the start of the text, at the start of a rich-inline item, or after a line break now stays with that zero-width space (#228).
- In Chrome, text prepared after changing
<html lang>now uses the fonts for the new language, even when the font string is unchanged (#230). - Figure spaces (U+2007) now keep adjacent text on the same line, like no-break spaces, as browsers do (#232).
- Lines can now break after
?before$,%,+,\,-or|, after!or?before a symbol such as©,¿or€, and after the Arabic semicolon؛before a word, as browsers do. Firefox still keeps?with a following-or|(#233). - A zero-width joiner now keeps the character after it on the same line, except right after a space and in CJK text (#233).
- In Chrome and Safari, a hyphen or dash such as U+2010 HYPHEN, U+2012 FIGURE DASH or U+2013 EN DASH at the start of a word now stays with a following letter of an alphabetic script, such as Latin, Cyrillic, Arabic, Hebrew or Thai. For
-, only letters outside Latin-1 count (#233). - In Chrome, lines can now break between a fullwidth closing bracket such as
」or)and a following ideograph, kana or Hangul syllable, as Chrome does (#234). - Lines no longer start with CJK closing punctuation or nonstarters such as
〟,],。,、,」or゛(#234). - With
word-break: keep-all, lines no longer break afterーin words such asラーメン. In Chrome, they also no longer break after iteration marks such as々,ゝorヽ(#234). - In Safari, a word followed by a space now keeps its kerning with that space, so letters such as
Ain Arial or Times New Roman fit narrow lines as they do natively (#236). - Reported line widths are now clamped at 0 instead of going negative, for example with strongly negative
letterSpacing(#236). - Chrome, Firefox, Edge and other browsers on iPhone and iPad, and in-app web views on iPhone, iPad and Mac, now wrap text as Safari does, since they use WebKit. Previously, some of them got rules meant for other browsers, such as breaks after punctuation with
word-break: keep-all. In Safari, text prepared in a web worker now gets the same rules as on the page (#237). - In Chrome and Firefox, a newline next to a zero-width space no longer adds a space in
white-space: normal, matching the browser (#238). - In Chrome, when the hyphen of a chosen soft hyphen does not fit, the line now ends at an earlier space, zero-width space or soft hyphen that leaves room for it, as Chrome does, instead of overflowing. With
letterSpacing, Chrome's visible hyphen no longer gets its own letter spacing (#239). - In Safari, a next-line character (U+0085) now stays on the same line as the text before it, and lines can still break after it.
letterSpacingno longer adds space after U+0085, except next to text that Safari shapes as complex text, such as Arabic, Devanagari or a combining mark (#240). - In Safari, a tab in
white-space: pre-wrapnow moves to the following tab stop when less than half a space would remain before the next one, as Safari does (#240). - In Chrome and Safari, rich-inline layout now breaks between items only where their joined text has a break opportunity. Punctuation such as
,or)at the start of an item stays with the word before it, and a word split across items wraps as one word. Items without a space between them can also break where the joined text allows it, such as between CJK characters, at Thai word boundaries or after-. In Safari, breaks inside each item still come from that item's own text, as Safari wraps each span, so a Thai, Lao, Khmer or Myanmar word split across items wraps like Safari's spans. Firefox still breaks at every item boundary (#241). - With
word-break: keep-allin Chrome and Firefox, lines can now break before an opening bracket such as(or¡after CJK text, as in서울(한국)에서, before「or(after Latin letters or digits, after a closing bracket such as❩before CJK text, and next to Thai text. In Chrome, they can also break next to emoji and symbols such as★or~, after punctuation such as/or‼that follows an emoji, after keycaps, between flags, and before an opening quotation mark or after a closing one between CJK characters, as in他说“你好”然后(#243). - A time or number followed by closing punctuation such as a full-width comma, as in
00:00:00,, now stays whole instead of breaking after a:or before the comma (#245). - In Safari, small kana and
ーafter CJK text can now start a line only on pages whose<html lang>is Japanese or Korean, as Safari does (#249). - In Chrome,
ーcan now start a line after CJK text, as Chrome does (#250). - In Firefox, and in engines Pretext doesn't recognize, small kana no longer start a line after CJK text, as Firefox does (#250).
- When a line's first word is wider than the line, a following space or zero-width space now ends that line in
layoutWithLines(),walkLineRanges(),layoutNextLine(),layoutNextLineRange()and rich-inline layout. Previously, other content such as a soft hyphen or a word joiner, orletterSpacing, moved it to the start of the next line. Plain-text line counts and widths don't change. WithletterSpacing, rich-inline layout can also take fewer lines or give lines different widths, for example where invisible characters such as a zero-width space took a line of their own (#272). - A negative
maxWidthnow lays out like 0 inlayout()and the other plain-text line APIs. Previously it could give a different line count than 0, which could also depend on whether the text contained a soft hyphen or usedletterSpacing(#272). - In Safari, a word that ends in an invisible format character such as a word joiner now keeps its kerning with a following space when an explicit bidi control such as U+202A appears only in another paragraph, such as another line of
white-space: pre-wraptext (#271). - In Firefox, a combining mark after a line break or a space now stays with a following
$,%,+or\, as it does at the start of the text. At narrow widths such text can also take one line fewer: after어, a space and U+3099,$"no longer breaks between$and"(#270). - With
word-break: keep-allin Chrome and Firefox, a URL containing a secondwww.or scheme such ashttps://before its query, as inx中www.a/www.b?q, no longer loses text. In Chrome and Safari, rich-inline layout no longer breaks such a URL where its text has no break opportunity, as before the secondwww.in items字andwww.a/www.b?q=1(#269).
- Streaming line layouts and line statistics now agree with batch layout when a later break follows a soft hyphen. Streaming also retains later text after consecutive lines containing only invisible break controls (#222).
- Terminal soft hyphens now stay invisible and preserve terminal letter spacing across the rich line APIs.
- Rich bidi metadata now resets independently at each paragraph boundary.
- Rich-inline preparation with long internal whitespace, streaming layout of long hyphenated runs, and long font-size strings now avoid excessive repeated work (#221).
- Rich-inline cursors now retain original item indices across empty items, zero-width items can occupy a line, and boundary spaces preserve their font and signed letter spacing. Mutating a visited line no longer changes the walker's continuation (#220).
- Overlong independent symbol runs can now wrap at grapheme boundaries, with browser-specific punctuation attachment (#208).
- Numeric minus signs no longer introduce a preferred break before their number, and ASCII hyphens after CJK text stay attached to the preceding character (#213, #215).
- The Markdown chat demo now keeps ordinary text inside its bubbles in Firefox on macOS (#202).
- The published package now ships declaration maps, so editor go-to-definition and programmatic TypeScript source tracing land in the shipped
.tssource instead of the.d.tsfiles.
- Word-internal keyboard and Unicode symbol runs in long words now stay with surrounding text the way browsers break them, while browser-break symbols stay breakable (#169).
- Overlong hyphenated runs now prefer browser-like dash breakpoints before falling back to emergency grapheme breaks (#89).
- The package now declares itself side-effect-free so bundlers can tree-shake unused entrypoints (#160).
layoutNextLine()andlayoutNextLineRange()now avoid redundant chunk lookup in chunk-heavy manual layout paths (#140).
{ wordBreak: 'keep-all' }now handles no-space mixed Latin, numeric, and CJK text more like browsers.- No-space punctuation chains now stay together for non-ASCII word-like text too, instead of only ASCII words.
- Opening punctuation such as
¡,¿, German low quotes, and⸘now stays with the following word instead of dangling at line end (#165). - Numeric prefix/postfix symbols like
$,%,€,+,−, and°now stay attached to adjacent text the way browser line breaking does (#105). - Soft-hyphen breaks now stay at the soft-hyphen insertion point instead of pulling post-hyphen graphemes onto the broken line (#162).
- Line geometry now preserves browser-style terminal letter spacing, including rich-inline item boundaries and visible soft-hyphen breaks (#171).
- Rich-inline item boundaries no longer overflow the requested width after a forced-progress break (#132).
- The markdown chat demo now drops parsed link URLs unless they resolve to HTTP(S) hrefs (#168).
- Numeric CSS-pixel
letterSpacingsupport onprepare(),prepareWithSegments(), and each existing rich-inline item (#108, #156).
- CJK text followed by opening bracket annotations now wraps like browsers instead of leaving the opening bracket on the previous line (#148).
- Geometry-first rich line helpers for manual layout work:
measureLineStats(),measureNaturalWidth(),layoutNextLineRange(), andmaterializeLineRange(). @chenglou/pretext/rich-inline, a narrow helper for inline-only rich text, mentions/chips, and browser-like boundary whitespace collapse.{ wordBreak: 'keep-all' }support onprepare()/prepareWithSegments()for CJK and Hangul text.- A virtualized markdown chat demo for rich inline text and
pre-wraplayout.
- Prepare-time analysis is more resilient on long mixed-script, CJK, Arabic, repeated-punctuation, and other degenerate inputs.
- Mixed CJK-plus-numeric runs, keep-all mixed-script boundaries, and long breakable runs now stay closer to browser behavior.
- Rich-path bidi metadata and CJK detection now handle the relevant astral Unicode ranges correctly.
- A justification comparison demo that shows native CSS justification, greedy hyphenation, and a Knuth-Plass-style paragraph layout side by side.
- Rich layout is faster on chunk-heavy and long-breakable text.
layout(),layoutWithLines(), andlayoutNextLine()stay aligned on narrowZWSP/ grapheme-breaking edge cases.- The justification comparison demo no longer paints justified lines wider than their column.
- npm now publishes built ESM JavaScript from
dist/instead of exposing raw TypeScript source as the package entrypoint. - TypeScript consumers now pick up shipped declaration files automatically from the published package, while plain JavaScript consumers can install and import the package without relying on dependency-side TypeScript transpilation.
{ whiteSpace: 'pre-wrap' }mode for textarea-like text, preserving ordinary spaces, tabs, and hard breaks.
- Safari line breaking is more accurate for narrow soft-hyphen and breakable-run cases.
Initial public npm release of @chenglou/pretext.
prepare()andlayout()as the core fast path for DOM-free multiline text height prediction.- Rich layout APIs including
prepareWithSegments(),layoutWithLines(),layoutNextLine(), andwalkLineRanges()for custom rendering and manual layout.