Skip to content

Markdown Feeds: Decode HTML entities in titles, tagline and excerpts - #1086

Merged
dkotter merged 4 commits into
WordPress:developfrom
ekamran:shifteq/markdown-feeds-decode-entities
Oct 5, 2026
Merged

dkotter merged 4 commits into
WordPress:developfrom
ekamran:shifteq/markdown-feeds-decode-entities

Conversation

@ekamran

@ekamran ekamran commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

What?

Closes #1085

Decodes HTML entities in the plain-text parts of the Markdown Feeds output: post titles, the site tagline and feed excerpts.

Why?

On develop those parts are served with entities left in, while the converted content and the site name next to them are plain text:

# Test Blog

Tips & Tricks

## It’s a “quoted” title

Titles go through wp_specialchars_decode( ..., ENT_QUOTES ), which only reverses the five special characters, so everything wptexturize produces (’, “, –, …) stays encoded. The tagline and excerpts are not decoded at all. Any title with an apostrophe or quotes is affected.

How?

  • Adds Markdown_Converter::decode_entities(), a thin wrapper around html_entity_decode() with ENT_QUOTES | ENT_HTML5 and the site's charset.
  • The feed renderer uses it for the site name, the tagline, item titles and excerpts. Excerpts are decoded after wp_strip_all_tags(), so an entity-encoded tag cannot turn into a real one and take text with it.
  • The singular renderer uses it for the title.
  • Content is untouched. The converter already decodes entities there, so this brings the rest of the document in line with it.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code and Codex
Used for: Investigation, implementation, tests, and PR wording. I reviewed the reasoning and test results, and I take responsibility for the contribution.

Testing Instructions

  1. Enable the Markdown Feeds experiment under Settings > AI.
  2. Set the tagline to Tips & Tricks and publish a post titled It's a "quoted" title.
  3. Open /feed/markdown/ and the post URL with ?output_format=markdown. The tagline reads Tips & Tricks and the title reads It’s a “quoted” title, with the entities decoded.
  4. Under Settings > Reading, switch the feed to Excerpt and reload the feed. The excerpt is plain text as well.

Automated:

  • npm run test:php -- --filter Markdown_ passes with 35 tests and 77 assertions. Five tests are new. The three renderer tests fail on develop with the entity strings above and pass here.
  • The same group passes with WP_MULTISITE=1.
  • The full PHP suite passes (1738 tests).
  • composer lint and PHPStan pass.

Also verified by hand on a local WordPress 7.1 site through /feed/markdown/ and ?output_format=markdown, before and after.

Changelog Entry

Fixed - Markdown Feeds: post titles, the site tagline and excerpts no longer contain HTML entities.

Open WordPress Playground Preview

Post titles, the site tagline and feed excerpts were written into the
Markdown document with their HTML entities intact (It’s, Tips &
Tricks), while the converted post content and the site name next to them
were already plain text. Titles were passed through wp_specialchars_decode(),
which only reverses the five special characters, and the tagline and
excerpts were not decoded at all.

Decode all of them with one helper on the converter so the whole document
is entity-free.
@ekamran
ekamran requested a review from a team October 1, 2026 10:08
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ekamran <ekamran@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>
Co-authored-by: rahultank-spaceo <rahultank@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.55%. Comparing base (f52eb36) to head (766fd9b).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #1086      +/-   ##
=============================================
+ Coverage      81.53%   81.55%   +0.01%     
- Complexity      3071     3072       +1     
=============================================
  Files            129      129              
  Lines          12253    12255       +2     
=============================================
+ Hits            9991     9994       +3     
+ Misses          2262     2261       -1     
Flag Coverage Δ
unit 81.55% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jeffpaul jeffpaul added this to the 1.5.0 milestone Oct 2, 2026
@jeffpaul

jeffpaul commented Oct 2, 2026

Copy link
Copy Markdown
Member

@dkotter this might be worth squeezing into 1.4.0

@yogeshbhutkar yogeshbhutkar 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.

This tests well 👍

Before After
Image Image

Comment thread includes/Experiments/Markdown_Feeds/Markdown_Converter.php Outdated
Use get_bloginfo( 'charset' ) instead of a hardcoded UTF-8 when decoding
entities in titles, the tagline and excerpts, so the decoded text is in the
charset the Markdown response declares. Nothing changes on UTF-8 sites.
@rahultank-spaceo

Copy link
Copy Markdown

Test Report

Patch tested: #1086 (commit 556223c), compared with develop (f52eb36)

Environment

  • WordPress: 7.1.2 (WordPress Playground)
  • PHP: 8.3
  • Plugin: AI, built from source (npm ci && npm run build)
  • Browser: Google Chrome 153.0.8010.52
  • OS: Linux
  • Theme: Twenty Twenty-Five

Steps

  1. Set the site tagline to Tips & Tricks.
  2. Published a post titled It's a "quoted" title, with an excerpt Dad's "best" recipes & more.
  3. Enabled the Markdown Feeds experiment and opened /?feed=markdown and ?p=<id>&output_format=markdown.
  4. Repeated with Settings → Reading → Excerpt enabled.
  5. Repeated the same steps with the PR applied.

Results

develop PR #1086
Tagline (feed) Tips &amp; Tricks Tips & Tricks ✅
Post title (feed, H2) It&#8217;s a &#8220;quoted&#8221; title It’s a “quoted” title ✅
Post title (singular, H1) It&#8217;s a &#8220;quoted&#8221; title It’s a “quoted” title ✅
Excerpt (feed, excerpt mode) Dad's "best" recipes &amp; more Dad's "best" recipes & more ✅

The converted post content (Hello & welcome.) was already correct on both branches. No PHP notices or warnings with WP_DEBUG enabled.

✅ The patch fixes #1085.

@dkotter dkotter modified the milestones: 1.5.0, 1.4.0 Oct 5, 2026
@dkotter
dkotter merged commit c5ce03a into WordPress:develop Oct 5, 2026
36 checks passed
@ekamran
ekamran deleted the shifteq/markdown-feeds-decode-entities branch October 5, 2026 13:16
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.

Markdown Feeds: titles, tagline and excerpts are served with HTML entities

5 participants