chenglou/pretext
45.8
Weak · 14 November 2026
23.1k
lines of production code
TypeScript
with C
7
measurements over time
What this system is
This system is a high-fidelity, cross-browser line layout engine designed to replicate complex text rendering behaviors found in modern browsers like Chrome, Firefox, and Safari. It provides precise grapheme segmentation, line-breaking, and rich-inline layout capabilities, validated against real-world browser implementations through an extensive regression testing harness. The project also includes a suite of interactive demos and performance benchmarks to demonstrate and measure its layout accuracy and efficiency.
Features
Introduce fresh-line geometry and grapheme cluster segmentation
Added \src/entry-geometry.ts\ to handle 'fresh-line geometry' (entry geometry), calculating widths for lines starting inside segments containing default-ignorable code points (like ZWNJ or word joiners) by measuring up to three prefix queries per segment. Added \src/graphemes.ts\ to implement grapheme cluster segmentation using Unicode 17 character rules, replacing reliance on the system's ICU for cluster detection and ensuring consistent behavior across engines. These modules support the line walkers in \src/line-break.ts\ by providing precise metrics for complex text boundaries.
src · high confidence
New and updated demo pages for layout capabilities
The demos location now includes several new interactive examples: an Accordion demo that calculates section heights without DOM measurement, a Bubbles demo demonstrating tight multiline message sizing, a Dynamic Layout demo with obstacle-aware text routing around logos, an Editorial Engine demo featuring animated orbs and multi-column flow, a Justification Comparison demo, a Rich Text demo, a Markdown Chat demo, and a Masonry demo. The index page has been updated to list these new demos, and the previous demo page structure has been replaced by this new organized set.
pages/demos · high confidence
New demo site build script and documentation citation tests
A new build script (scripts/build-demo-site.ts) was added to compile and publish the demo site, handling entry points, asset rebasing, and link rewriting for static deployment. Additionally, a new test suite (scripts/doc-citations.test.ts) was introduced to validate that all internal documentation citations reference existing repository documents and valid headings, ensuring documentation integrity.
scripts · high confidence
New grapheme-check tool to validate grapheme segmentation against browser Intl.Segmenter
A new grapheme-check tool has been added to the scripts directory to verify the project's grapheme segmentation logic against the browser's native Intl.Segmenter API. The tool builds a web page that runs the check in pinned browsers (Chrome, Firefox, WebKit) or offline under Node/Bun, comparing the project's \findGraphemeEnds\ implementation against the browser's segmentation on harness case texts, specific Unicode contexts, and randomized fuzzing. Results are written to \.artifacts/grapheme-check/\<browser\>.json\ to help identify discrepancies between the custom implementation and browser standards.
scripts/grapheme-check · high confidence
New layout harness for browser layout regression testing
The repository now includes a new harness for recording and scoring browser layout behavior. It records the layout of paragraphs in pinned versions of Chrome, Firefox, and Safari (via webkit-host), then predicts layouts using the library and scores them against the recordings. The harness supports two tiers of test cases: a real-usage sample weighted by typical app surfaces, and a behavior catalog covering specific edge cases. It provides CLI commands to record layouts, check predictions, run offline invariants, and compare builds.
harness · high confidence
New masonry layout demo with virtualized rendering
A new interactive demo has been added at pages/demos/masonry that showcases a virtualized masonry layout engine. The implementation pre-renders text using a specific font configuration and applies word-breaking rules consistent with the Pretext library. It features a custom layout algorithm that calculates proportional column widths and centers the grid, while using an array-based DOM cache to efficiently manage visibility and positioning for large datasets (up to 10k cards) without impacting performance.
pages/demos/masonry · high confidence
New performance benchmarking harness for line layout engines
Adds a new \harness/bench\ directory containing a comprehensive performance benchmarking tool for comparing line layout implementations across browsers. The harness includes a detailed README explaining the measurement protocol, noise floors, and row definitions (e.g., \new\, \rich\, \worst\), along with TypeScript source files (\lib.ts\, \page.ts\, \report.ts\, \run.ts\) that handle build bundling, browser session management, and statistical reporting. It also includes a test suite (\bench.test.ts\) verifying the verdict logic, report formatting, and session handling. This tool allows developers to measure and compare the performance of layout changes in Chrome, Firefox, and WebKit using side-by-side background windows or foreground modes, with calibrated noise thresholds to distinguish real performance changes from measurement variance.
harness/bench · high confidence
Behavioural changes
1021 commits (76 fixes) modifying (repo-wide)
A change to existing behaviour in (repo-wide) — 1021 commits (76 fixs), 20 files.
(repo-wide) · low confidence · unverified
Cursor rule file converted from symlink to regular file
The rule file located at .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc has been converted from a symbolic link to a standard file. This change ensures the rule content is stored directly within the repository rather than pointing to an external location, which may improve reliability in environments where symbolic links are not preserved or supported.
.cursor · high confidence
Redirect home page to demos and remove obsolete placeholder pages
Visiting the root path now automatically redirects to the /demos section, replacing the previous home page. The standalone placeholder pages for accuracy, benchmark, demo, and interleaving have been removed, as their content has been consolidated or moved into the demos directory.
pages · high confidence
Updated ICU data for Chrome 153 engine
The Chrome 153 engine data has been updated to align with the version's ICU character rules and properties. This includes new grapheme cluster detection logic, updated line-break tables (including specific handling for Chinese/Japanese text), and refreshed Unicode character property data, ensuring text processing behavior matches the underlying ICU library version bundled with Chrome 153.
scripts/engine-data/chrome-153 · medium confidence · unverified
Updated Safari 27.0 text layout and locale data
The Safari 27.0 engine data has been updated to improve text rendering accuracy. Grapheme cluster detection now uses the engine's specific ICU character rules, and line-break behavior is driven by each engine's own line-break tables and scans. Additionally, Safari's generic font families are now correctly named for every page language based on Core Text's table, ensuring consistent typography across different locales.
scripts/engine-data/safari-27.0 · medium confidence · unverified
Updated engine data for line breaking, grapheme clustering, and WebKit generic font families
The generated engine data has been refreshed to align with ICU 78.2 and libicucore 78.1 rules for line breaking and grapheme clustering, incorporating updated state tables and character property data for Chromium, Apple, and Gecko engines. Additionally, a new generated file provides WebKit's generic font family mappings (serif, sans-serif, etc.) indexed by language and script subtag, ensuring accurate font resolution across different locales.
src/generated · high confidence
Updated line-breaking test data and engine-specific behavior facts
The test harness now includes the normative Unicode Line Breaking Algorithm data (version 17.0.0) to ensure alignment with the latest standard. Additionally, the \engine-facts.json\ file has been expanded to document specific line-breaking behaviors across Chrome, Firefox, and Safari, covering edge cases such as soft hyphen handling, tab stops in \pre-wrap\ mode, and CJK text segmentation. The \rule-families.ndjson\ dataset has also been updated to include new test cases for emergency word breaks and control character handling.
harness/sets/data · high confidence
Test coverage
Add book corpus test cases to the harness; Introduce new harness case-set generators and build infrastructure.
Dependencies
Publish @chenglou/pretext package with TypeScript 6 support
The project has been renamed to @chenglou/pretext and published as a public npm package, exposing layout and rich-inline APIs via ESM exports. The package now targets TypeScript 6.0.2 (upgraded from peer dependency ^5) and includes dev dependencies for knip and marked. The package surface is defined with specific entry points, side-effect-free marking, and file inclusions for distribution.
(dependencies) · high confidence
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.
Score
- CAI 45 → 46 (+0.7)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.4) — scores are not directly comparable.
Lenses
- Code Health 34 → 34 (-0.0)
- Architecture 99 → 99 (-0.0)
- Maturity 66 → 66 (+0.0)
- Readiness 40 → 41 (+0.7)
- Security 74 → 86 (+11.6)
- Performance 60 → 60 (+0.0)
Resolved (19)
- FileTooLong: scripts/generate-engine-break-data.ts (scripts/generate-engine-break-data.ts)
- Hotspot: harness/bench/report.ts (harness/bench/report.ts)
- Hotspot: harness/offline-equal.ts (harness/offline-equal.ts)
- Hotspot: harness/sets/sample.ts (harness/sets/sample.ts)
- Hotspot: scripts/generate-engine-break-data.ts (scripts/generate-engine-break-data.ts)
- Medium: security finding (details withheld)
- No ADRs found
- No SBOM
- No artifact signing
- No build provenance
- Unpinned build actions
- check.runGraphemeCheck (cognitive 43) (scripts/grapheme-check/check.ts)
- check.runGraphemeCheck (cyclomatic 23) (scripts/grapheme-check/check.ts)
- generate-engine-break-data.checkSinglePass (cognitive 16) (scripts/generate-engine-break-data.ts)
- generate-engine-break-data.findRowDifferences (cognitive 17) (scripts/generate-engine-break-data.ts)
- generate-engine-break-data.getGeckoClusterEnds (cognitive 46) (scripts/generate-engine-break-data.ts)
- generate-engine-break-data.getGeckoClusterEnds (cyclomatic 19) (scripts/generate-engine-break-data.ts)
- generate-engine-break-data.packTable (cognitive 21) (scripts/generate-engine-break-data.ts)
- generate-webkit-generic-families.readFamilies (cognitive 16) (scripts/generate-webkit-generic-families.ts)
New (13)
- Medium: security finding (details withheld)
- No ADRs found (package.json)
- redundant comment (harness/bench/report.ts)
- redundant comment (harness/bench/run.ts)
- redundant comment (harness/cli.ts)
- redundant comment (harness/harness.test.ts)
- redundant comment (harness/harness.test.ts)
- redundant comment (harness/predict.ts)
- redundant comment (harness/predict.ts)
- redundant comment (harness/score.ts)
- redundant comment (harness/store.ts)
- redundant comment (src/line-text.ts)
- redundant comment (src/measurement.ts)
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
chenglou/pretext was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 14 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 0d102a5cd933611e86a7e60bda7b4baa5995c6b0 — the exact code this score is about.
- Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
- Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.65+preprod-e1a3b69fc8ee.