Skip to content

Apply LB30 East Asian exception for opening punctuation - #53

Open
dngr2 wants to merge 1 commit into
foliojs:masterfrom
dngr2:lb30-east-asian-opening-punctuation
Open

Apply LB30 East Asian exception for opening punctuation#53
dngr2 wants to merge 1 commit into
foliojs:masterfrom
dngr2:lb30-east-asian-opening-punctuation

Conversation

@dngr2

@dngr2 dngr2 commented Aug 17, 2026

Copy link
Copy Markdown

Rule LB30 only prohibits a break before opening punctuation when the bracket is not East Asian (wide / fullwidth / halfwidth). The library treated all OP the same, so it wrongly prohibited breaks before wide brackets:

// "#〈" (U+0023 U+2329) and "p(" (U+0070 U+FF08)
[...new LineBreaker("#〈")]  // offered no break before the wide bracket

generate_data.js now also reads EastAsianWidth.txt and puts East Asian opening punctuation / closing parens in their own break classes (OP_EA / CP_EA), so LB30's exception applies. This makes 15 of the previously-skipped LineBreakTest.txt rows pass — I removed those from the skip list. The remaining skips are the numeric (LB25) tailoring cases, which are unaffected. npm test: 7610 passing, 44 pending.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Unicode line-breaking data generation and pair table so Rule LB30’s East Asian exception is applied to wide/fullwidth/halfwidth opening punctuation (and related closing parens), fixing previously incorrect “no-break” behavior before wide brackets and allowing more LineBreakTest.txt rows to pass.

Changes:

  • Extend generate_data.js to fetch and parse EastAsianWidth.txt, splitting OP/CP into OP_EA / CP_EA during trie generation.
  • Expand the pair table to include the new East Asian-specific break classes.
  • Reduce the LineBreakTest.txt skip list now that more cases pass.

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/index.js Removes now-passing test rows from the skip list.
src/pairs.js Adds OP_EA / CP_EA columns/rows to the pair table for LB30 East Asian handling.
src/generate_data.js Fetches/parses EastAsianWidth.txt and assigns OP_EA / CP_EA during trie generation.
src/classes.js Introduces new break-class constants for East Asian OP/CP and renumbers following classes.
src/classes-trie-data.js Updates generated trie data to reflect the new class assignments.
Files not reviewed (2)
  • src/classes-trie-data.js: Generated file
  • src/pairs.js: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/pairs.js Outdated
[IN_BRK, PR_BRK, PR_BRK, IN_BRK, IN_BRK, IN_BRK, PR_BRK, PR_BRK, PR_BRK, IN_BRK, IN_BRK, IN_BRK, IN_BRK, IN_BRK, DI_BRK, IN_BRK, IN_BRK, IN_BRK, DI_BRK, DI_BRK, PR_BRK, CI_BRK, PR_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, IN_BRK, DI_BRK, IN_BRK, PR_BRK], // ZWJ
[DI_BRK, PR_BRK, PR_BRK, IN_BRK, IN_BRK, DI_BRK, PR_BRK, PR_BRK, PR_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, PR_BRK, CI_BRK, PR_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, IN_BRK, DI_BRK, DI_BRK, PR_BRK], // CB
[PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, CP_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK], // OP_EA
[DI_BRK, PR_BRK, PR_BRK, IN_BRK, IN_BRK, PR_BRK, PR_BRK, PR_BRK, PR_BRK, IN_BRK, IN_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, IN_BRK, IN_BRK, IN_BRK, DI_BRK, DI_BRK, PR_BRK, CI_BRK, PR_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, DI_BRK, IN_BRK, DI_BRK, DI_BRK, PR_BRK], // CP_EA
Comment thread src/generate_data.js
Comment on lines +54 to +61
request(`${BASE}EastAsianWidth.txt`, function (eawErr, eawRes, eawData) {
const isEastAsianWide = parseEastAsianWide(eawData);

// this loads the LineBreak.txt file for Unicode and parses it to
// combine ranges and generate JavaScript
request(`${BASE}LineBreak.txt`, function (err, res, data) {
const matches = data.match(/^[0-9A-F]+(\.\.[0-9A-F]+)?;[A-Z][A-Z0-9]([A-Z])?/gm);

Rule LB30 prohibits a break before opening punctuation only when the bracket
is not East Asian wide/full/halfwidth, but all OP was treated the same, so a
break before a wide bracket such as U+2329 or U+FF08 was wrongly prohibited.
generate_data.js now also reads EastAsianWidth.txt and puts East Asian opening
punctuation in its own class (OP_EA) so LB30's exception applies. Un-skips the
15 LineBreakTest.txt rows this fixes.
@dngr2
dngr2 force-pushed the lb30-east-asian-opening-punctuation branch from 17fafcc to 7c6c20a Compare August 17, 2026 01:56
@dngr2

dngr2 commented Aug 17, 2026

Copy link
Copy Markdown
Author

Addressed the review: dropped the CP_EA class (Unicode 15 has no East Asian CP characters, so it had no members and its row was confusingly equal to CL) — only OP_EA is needed. Also added a status/error check to the EastAsianWidth.txt fetch. Suite still 7610 passing, 44 pending.

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.

2 participants