Skip to content

fix(check): a nested line's words stay out of the line around it - #7705

Open
wonjangcloud9 wants to merge 1 commit into
heygen-com:mainfrom
wonjangcloud9:fix/check-nested-line-text
Open

wonjangcloud9 wants to merge 1 commit into
heygen-com:mainfrom
wonjangcloud9:fix/check-nested-line-text

Conversation

@wonjangcloud9

Copy link
Copy Markdown
Contributor

Context: I've been using HyperFrames every day for the past two weeks to make Korean Shorts and long-form videos, and it's been great to work with. This PR is one of a batch of fixes for things I ran into along the way, so you'll see several PRs from me at once — sorry for the pile-up, and thanks for your patience. Each one is reproduced on current main, independent of the others, and can be reviewed, merged or closed on its own.

What

The craft sampler no longer counts a nested reading block's words a second time in the block around it. The same text is no longer reported twice by line_unread, once on the parent and once on the child.

Why

craftTextParts (packages/cli/src/commands/layout-audit.browser.js) gave every text element the innerText of its reading block. innerText includes block-level children, which readingBlock treats as lines of their own. An end card like

<div id="p3-pp0" class="pp">설계자 <div>코드는 코덱스</div></div>

turned into two lines, and both were reported:

line_unread | #p3-pp0                       | The film's last line "설계자 코드는 코덱스" (3 words) …
line_unread | #p3-pp0 > div:nth-of-type(1)  | The film's last line "코드는 코덱스" (2 words) …

The child's two words were counted in both lines. A mid-film title with a nested subtitle <div> gets the same double warning and an over-counted floor. This happens on any flex row too: a flex container's children are block-level, so .hd { display:flex } with <div>!</div>EMERGENCY ALERT<div>now</div> was read as "! EMERGENCY ALERT now".

Related work

How

  • New readingBlockText(block, root): if any child node is a reading block of its own (readingBlock(child) === child, not counting <br>), the block's text is built from its own text nodes and inline children, and each nested block becomes a separator. Otherwise it returns innerText as before.
  • Computed once per block per sample (a Map in craftTextParts), where it used to run once per text element. For a line split into one span per glyph, that is one read instead of one per glyph.

Test plan

  • New happy-dom test keeps a nested line's words out of the line around it (layout-audit.browser.test.ts) fails on main (the outer line reads "설계자 코드는 코덱스") and passes with the fix. A second test keeps inline word spans as one line.
  • layout-audit.browser.test.ts: 222 passed. layout-audit.chromium.test.ts run locally with PUPPETEER_EXECUTABLE_PATH set to chrome-headless-shell: 83 passed.
  • Real CLI on an end-card repro (hyperframes check --no-cache --json, card held 1.5 s):
    • main: #p3-pp0 "설계자 코드는 코덱스" (3 words) and #p3-pp0 > div:nth-of-type(1) "코드는 코덱스" (2 words).
    • this branch: #p3-pp0 "설계자" (1 word) and the child "코드는 코덱스" (2 words). No words are counted twice.
  • oxlint, oxfmt, fallow audit --base origin/main, typecheck (pre-commit).

Each chunk of a closing card is still reported as its own "film's last line". I am raising that separately, since it is a reporting-shape question.

🤖 Generated with Claude Code

The craft sampler read a block's text with innerText, which takes in every
descendant, including block-level children that the sampler reads as lines of
their own. A card like `<div>설계자 <div>코드는 코덱스</div></div>` became two
lines, "설계자 코드는 코덱스" (3 words) and "코드는 코덱스" (2 words), so the nested
words were counted twice and the same text was reported twice by line_unread.

A block with a nested reading block now leaves that child's text out of its
own; blocks without one keep the innerText reading. The block text is also
computed once per block per sample instead of once per text element.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
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.

1 participant