mozilla / mozilla/readability

PHRASING_ELEMS missing <u>, <s>, and <bdi> elements causes paragraph splitting

Open Beginner friendly
#997 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
11.5k
Forks
732
PR merge metrics
No merged PRs in 30d

Description

Problem

The PHRASING_ELEMS array is missing several HTML5 phrasing content elements: U, S, and BDI.

This causes Readability to incorrectly treat these inline elements as block-level, splitting paragraphs around them.

Example

Input HTML:

<p>Seigneur, mon Die<u>u</u> et mon salut</p>

Output (incorrect):

<p>Seigneur, mon Die</p><u>u</u><p> et mon salut</p>

The <u> tag is being treated as a block element, breaking the paragraph into three parts.

Solution
Add the missing phrasing content elements to PHRASING_ELEMS:

 PHRASING_ELEMS: [
   // ... existing elements ...
  "BDI",  // Bidirectional text isolation
  "S",    // Strikethrough
  "U",    // Underline
   // ...
 ]

Per HTML spec, these are all valid phrasing content elements that should be kept inline within paragraphs.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search the codebase for the PHRASING_ELEMS array and inspect the tests covering paragraph splitting or phrasing elements. Add BDI, S, and U to the array, then run the relevant test suite and confirm that the example remains one paragraph while existing behavior is unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, javascript
Domain
web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.