Skip to content

fix(Readability): treat S and BDI as phrasing content#1011

Open
SAY-5 wants to merge 2 commits into
mozilla:mainfrom
SAY-5:fix/phrasing-elems-u-s-bdi
Open

fix(Readability): treat S and BDI as phrasing content#1011
SAY-5 wants to merge 2 commits into
mozilla:mainfrom
SAY-5:fix/phrasing-elems-u-s-bdi

Conversation

@SAY-5

@SAY-5 SAY-5 commented May 19, 2026

Copy link
Copy Markdown

PHRASING_ELEMS is missing the HTML5 phrasing elements S and BDI, so Readability treats them as block-level and splits paragraphs around them (e.g. <div>foo <s>bar</s> baz</div> becomes <p>foo </p><s>bar</s><p> baz</p>). This adds both to PHRASING_ELEMS with a regression test.

Towards #997. I left U out for now because adding it changes the extracted output of the hukumusume test page, so that one is better handled separately.

@SAY-5 SAY-5 force-pushed the fix/phrasing-elems-u-s-bdi branch from e3eb4f3 to 888a768 Compare June 2, 2026 21:18

@gijsk gijsk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the patch.

The testcase is a bit strange. We would typically add a minimal testcase to the testcases folder instead, with source and expected output.

I also think that we should include u and update the testcases accordingly (generate-testcase.js can do this for you if you delete the expected.html file first and then run it with the testcase slug as an argument). Or at least - I would like to see what changes that causes, before deciding whether any of these changes make sense. In isolation it is hard to see what this is really accomplishing.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@SAY-5

SAY-5 commented Jul 10, 2026

Copy link
Copy Markdown
Author

Good points, thanks. Dropped the ad-hoc unit test and added a proper testcase under test-pages/phrasing-elements-s-bdi-u (source + expected regenerated with generate-testcase.js). I also added U to PHRASING_ELEMS as you suggested.

The fixture makes the effect visible: without these tags in the list, the run gets shattered into separate

blocks with the // nodes stranded outside the paragraphs; with them included the whole run stays in one

. The second div in the source keeps a real block boundary so the grouping is actually exercised.

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