Skip to content

Show HTML entities in article text as their characters - #67

Merged
bonelifer merged 1 commit into
mainfrom
article-text-entities
Oct 14, 2026
Merged

bonelifer merged 1 commit into
mainfrom
article-text-entities

Conversation

@bonelifer

Copy link
Copy Markdown
Contributor

Fixes #66. As on MediaWiki, an entity written in a wiki article now shows as the character it stands for. Before, that only happened inside a template's output.

  • In the text: s9e's HTMLEntities plugin is loaded, and its tag is switched on only while wiki markup is (wikilink_listener::toggle_wiki_markup()), like the wiki's other tags.
  • In captured text: headings, link texts and targets, category names and file alt texts are captured in one piece, and the plugin never sees them. An attribute filter, markup::decode_entities(), decodes them at the same moments. In a link target or category name, a non-breaking space counts as a space, as in MediaWiki page names.
  • Safe: the character is output as text, so <b> shows as "" and never becomes markup. An unknown entity, or one for a control character, stays as written.
  • Not in forum posts: both only apply while wiki markup is on, so posts, [[links]] in posts included, show entities as written, as before.
  • Not twice in templates: template text has already been decoded once on its way to the parser, so templates::render() and page_view() switch decoding off (markup::set_entities()). &amp;lt; in a template still shows "<".
  • Existing articles show their entities as written until they're saved again or reparsed. The README says so, next to the other markup.

Claude tested this through the edit form's preview on a seed-forum wiki test board (phpBB 3.3):

  • A&nbsp;B, A&#32;B and A&mdash;B show their characters, in text, a heading, a link's text and a link's target;
  • &lt;b&gt; and &amp;lt; show as "" and "<", and &bogus; stays as written;
  • a forum post keeps its entities as written;
  • &amp;lt; in a template is not decoded twice.

Two new unit tests. The full suite passes on phpBB 3.3 and master with run-unit-tests.sh. The 30 examples in phpbbmodders/wiki-templates still pass on this branch.


Investigated and written by Claude on behalf of William Jacoby (bonelifer).

🤖 Generated with Claude Code

As on MediaWiki, &nbsp;, &#32;, &mdash; and other entities written in a
wiki article now show as their characters: in the text through s9e's
HTMLEntities plugin, and in headings, link texts, link targets,
categories and file alt texts through an attribute filter, since the
plugin never sees text captured in one piece. A non-breaking space in a
link target counts as a space, as in MediaWiki page names. The character
is output as text, so &lt;b&gt; shows as "<b>", and an unknown or
control-character entity stays as written.

Both switch on only while wiki markup is, so forum posts are unchanged,
and not while template text is re-parsed (templates::render(),
page_view()), which has already been decoded once, so &amp;lt; in a
template still shows &lt;.

Fixes #66

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bonelifer
bonelifer merged commit 774fa61 into main Oct 14, 2026
58 checks passed
@bonelifer
bonelifer deleted the article-text-entities branch October 14, 2026 22:10
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.

HTML entities in article text are shown as written instead of as characters

1 participant