Support opt-in template transclusion on Markdown pages#16
Merged
Conversation
For #4 Add $wgNativeMarkdownTemplateTransclusion (default false). When on, `{{...}}` on Markdown pages expands via MediaWiki's parser, so infobox, citation and navbox templates render with dependency tracking (editing a template reparses the pages using it), recursion/size limits, and wikitext-level sanitization. Own-line calls render as block HTML (infoboxes are not paragraph-wrapped and may span multiple lines); inline calls render within text. The pure Application layer stays MediaWiki-free behind a TemplateExpander port; the adapter reuses one parser per render and merges each child ParserOutput into the page. Delegating to the parser also enables parser functions and magic words inside the braces, amending the SPEC's "no parser functions or magic words" non-goal (approved when directing this build). Deferred, and documented in the README: `<ref>`/`<references/>` in the Markdown body and cross-call citation state, `{{:MarkdownPage}}` full-page transclusion, and subst. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses findings from a self-review of the transclusion PR:
- registerSections now authoritatively rebuilds the table of contents from the
page's own markdown headings, overwriting any TOCData/SHOW_TOC a transcluded
template merged in. This fixes template headings leaking into the ToC of a
page that has no headings of its own.
- Extract TemplateBraces (matchLeadingCall + depthDelta) as the single balanced
`{{...}}` definition shared by the inline and block parsers, replacing the
duplicated brace scans.
- Strengthen tests: block calls keep their paragraph while inline calls strip
it; `{{...}}` in a GFM table cell with an escaped pipe; the ToC stays clean
when the page's only content is a heading-bearing template.
- README: note that an unclosed block `{{` renders as literal text to page end.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
JeroenDeDauw
added a commit
that referenced
this pull request
Jul 6, 2026
Follows-up to #16 Flip $wgNativeMarkdownTemplateTransclusion to true. $wgNativeMarkdownEverywhere already defaults to true, so out of the box every prose page is Markdown; with transclusion off, shared infoboxes, navboxes and citation templates render as literal {{...}} across the wiki. Turning it on completes the wiki integration with no cost to the AI story (action=raw still returns literal {{...}}) or to safety (parser output is sanitized as on any wikitext page). Co-Authored-By: Claude Opus 4.8 (1M context) <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.
For #4
Add $wgNativeMarkdownTemplateTransclusion (default false). When on,
{{...}}on Markdown pages expands via MediaWiki's parser, so infobox, citation and
navbox templates render with dependency tracking (editing a template reparses
the pages using it), recursion/size limits, and wikitext-level sanitization.
Own-line calls render as block HTML (infoboxes are not paragraph-wrapped and
may span multiple lines); inline calls render within text. The pure Application
layer stays MediaWiki-free behind a TemplateExpander port; the adapter reuses
one parser per render and merges each child ParserOutput into the page.
Delegating to the parser also enables parser functions and magic words inside
the braces, amending the SPEC's "no parser functions or magic words" non-goal
(approved when directing this build). Deferred, and documented in the README:
<ref>/<references/>in the Markdown body and cross-call citation state,{{:MarkdownPage}}full-page transclusion, and subst.