Repository navigation
Add Wikipedia-style headings, section links and a table of contents - #39
Merged
Merged
Conversation
== Heading == to ====== Heading ====== become h2 to h6 with anchors, a table of contents shows after the intro for four or more headings (__TOC__ places it, __FORCETOC__ forces it, __NOTOC__ hides it), [[Article#Section]] and [[#Section]] link to a heading, and a first line #REDIRECT [[Article]] sets the redirect. The text parser reads this only while a wiki article is saved or previewed, so forum posts are unchanged. A migration rebuilds the text formatter and reparses saved articles. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
bonelifer
force-pushed
the
feature/wikitext-headings
branch
from
October 12, 2026 19:14
74bbffa to
256dfd8
Compare
Contributor
Author
|
Rebased onto Investigated and written by Claude on behalf of William Jacoby (bonelifer). |
bonelifer
added a commit
that referenced
this pull request
Oct 12, 2026
…t changes columns (#40) Three fixes found while taking screenshots for the update post. All three come from #39 (headings and table of contents). **Section links showed no text.** `[[#Section]]` rendered an empty link, so "See [[Getting Started#Editing]] and [[#Publishing]]" read "See Getting Started and ." They now show the article name plus `#section`, as MediaWiki does: `[[#Publishing]]` shows "#Publishing" and `[[A#B]]` shows "A#B". An explicit label (`[[A#B|label]]`) is unchanged. **Fresh CLI installs had no wiki tags.** `add_wiki_markup` rebuilds the text formatter cache while the extension is being enabled, before the extension's listeners are registered. The cache it stored had no wiki tags, so `[[links]]`, `[[File:]]` embeds and headings did not parse until something purged the cache. The new migration `purge_text_formatter_cache` runs after it and clears the cache, so phpBB rebuilds it with the wiki's tags on the next page. `add_wiki_markup` itself is untouched, because it may already have been applied on existing boards. **Correction to #39:** its description said a migration reparses saved articles. It does not. Articles saved earlier are converted with `php bin/phpbbcli.php reparser:reparse phpbbmodders_wiki_article`. The README already said this; `docs/TODO/todo-wiki-markup.md` now matches it. **Recent changes columns.** The Reason and Status headers had the `big` class, which squeezed the Article column. Status is now `middle` and Reason has no width class. **Screenshots.** `docs/update/2026-10-12/` holds the screenshots for the update post, plus a `README.md` that shows them all. The folder is export-ignored, so it is not in the release zip. **Tests** - Unit tests: 124 tests, 257 assertions, all pass. They include a new `link_texts` data provider with five cases. - Fresh install with no manual cache purge, then fixtures seeded: MySQL 8.0 and PostgreSQL 16 both show 48 of 86 articles with `WIKILINK` tags and 2 with `WIKIFILE`. - `wiki-markup-test.js` browser run: 13 of 13 on phpBB 4.0.0-a3-dev with SQLite. On 3.3.19 with SQLite the first 10 checks pass. I stopped it there because the next check needs a user without the redirect permission, and that board only has `admin`. --- Investigated and written by [Claude](https://www.anthropic.com/claude) on behalf of William Jacoby ([bonelifer](https://github.com/bonelifer)). --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
First step of the Wikipedia-syntax work in
docs/TODO/todo-wiki-markup.md: headings and a table of contents, plus the links that point at them. It also closes the "Table of contents" item indocs/TODO.md.== Heading ==to====== Heading ======on a line of their own become h2 to h6 with an anchor. Repeated headings get_2,_3. A line that does not match exactly (a == b,== unfinished, seven=) stays text.__TOC__places it where it is written and shows it for any number of headings,__FORCETOC__shows it for any number,__NOTOC__hides it. Its title is translated (English and German).[[Article#Section]],[[Article#Section|text]]and[[#Section]](a link into the same page) point at the heading's anchor. They also work in forum posts, as[[links]]already do.#REDIRECT [[Article]]. A first line like this sets the article's redirect, for members who may set redirects; for everyone else it stays text.__…__words only while a wiki article is saved or previewed: the tags are switched on incore.text_formatter_s9e_parse_beforeand off again straight after, so in a forum post, private message or signature== text ==and__TOC__stay plain text. The anchors and the table of contents are built when the article is shown, from the rendered headings, so they never go stale.== text ==, or one of the__…__words, now means what it means in MediaWiki.reparser:reparse) now reads the same markup, so==lines in older articles become headings.Not in this PR: text styles (
'''bold''', lists), references, tables, categories and templates, and a setting to turn the Wikipedia markup off for a whole board.Testing
Claude ran a 13-check browser script on a phpBB 4.0 (master) board seeded with the wiki fixtures, and again on fresh phpBB 3.3.19 boards with MySQL 8.0 and with PostgreSQL 16 (13 of 13 on each):
_2, the box lists1 History / 1.1 Early years / 1.2 Later years / 2 History / 3 See also, sits after the intro and before the first heading, and its links jump to the headings;__TOC__places it and shows it for two headings;__NOTOC__hides it with five headings;[[#Early years]]as a same-page link;#REDIRECT [[Main Page]]sets the redirect for a moderator and sets nothing for an editor who may not set redirects;== Not a heading ==and__TOC__stay plain text while[[Main Page#Part]]still links.On the 4.0 and 3.3 boards the reparser was run on an article saved before the change, and its
==line became a heading; screenshots of the contents box on both boards look right. 31 new unit tests cover anchors, the redirect line, the contents markup (balanced when levels jump),__TOC__/__NOTOC__/__FORCETOC__, and the parser configuration with the real s9e library (heading levels, near-misses that stay text, tags off when the markup is off, magic words, section links, broken links,[[File:]]unchanged). All 109 wiki unit tests pass, and the new and changed PHP files lint clean on PHP 8.5.Investigated and written by Claude on behalf of William Jacoby (bonelifer).