Skip to content

Convert <br> tags to spaces in API-provided excerpts - #25875

Open
crazytonyli wants to merge 2 commits into
trunkfrom
fix/reader-excerpt-br
Open

Convert <br> tags to spaces in API-provided excerpts#25875
crazytonyli wants to merge 2 commits into
trunkfrom
fix/reader-excerpt-br

Conversation

@crazytonyli

Copy link
Copy Markdown
Contributor

Description

Relates to #25392. Reader posts almost always carry an API-provided excerpt, and formatSummary stripped its HTML with a plain tag stripper, so <br>-separated words still ran together in the feed.

To reproduce the issue: publish a post with an author-set excerpt containing a <br> tag (e.g. Yes,<br>look behind), then view it in the Reader feed. The cell shows "Yes,look behind". This only reproduces with author-set excerpts; WordPress.com strips <br> server-side when it auto-generates an excerpt from post content, which a client-side fix can't repair.

Before After

The break-aware excerpt handling added in #25392 only ran when a summary
was generated from post content. Reader posts almost always carry an
API-provided excerpt, and formatSummary stripped its tags with an empty
replacement, so <br>-separated words ran together (e.g. "Yes,<br>look
behind" rendered as "Yes,look behind").

Extract the generator's break-aware plain-text conversion into
GutenbergExcerptGenerator.singleLinePlainText(from:), bridge it to
Objective-C as wpkit_makeSingleLinePlainText, and use it when formatting
API-provided excerpts. Titles and site metadata keep the generic
plain-text conversion.

Note: WordPress.com pre-strips <br> when it auto-generates an excerpt
from post content, so this only repairs author-set excerpts; the
auto-generated case is mangled server-side before the app sees it.
formatSummary always returns a non-nil string, so the nil check guarding
the createSummaryFromContent fallback never fired: posts whose API
excerpt was empty ended up with an empty summary instead of one crafted
from the post content, and the content-based generator integrated in
#25392 was unreachable on the Reader path. Check for an empty string
instead of nil so the fallback works as documented.
@crazytonyli crazytonyli added this to the 27.2 milestone Aug 7, 2026
@crazytonyli
crazytonyli requested a review from jkmassel August 7, 2026 02:45
@wpmobilebot

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number33648
VersionPR #25875
Bundle IDorg.wordpress.alpha
Commit1648b59
Installation URL1lv3ofisb474g
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number33648
VersionPR #25875
Bundle IDcom.jetpack.alpha
Commit1648b59
Installation URL1j3dbitfn2kno
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@crazytonyli
crazytonyli enabled auto-merge August 7, 2026 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants