Unlike most Wikidot constructs that are handled during AST parsing, include
directives are resolved as a text-level macro expansion BEFORE the main parse.
This is necessary because included content may contain partial block structures
(e.g., an opening [[div]] tag in one include and its closing [[/div]] in
another) that must be visible to the parser as a single continuous text.
The resolution process:
Scan the source text for [[include page | var=val]] patterns
Fetch the included page's content via the provided fetcher callback
Apply variable substitutions ({$key} -> value)
Recursively resolve includes in the fetched content (up to max depth)
Replace the original [[include ...]] directive with the expanded text
Safety features include circular dependency detection (using a trace of
visited pages) and a configurable maximum recursion depth (default: 5).
Text-level expansion of
[[include]]directives.Unlike most Wikidot constructs that are handled during AST parsing, include directives are resolved as a text-level macro expansion BEFORE the main parse. This is necessary because included content may contain partial block structures (e.g., an opening
[[div]]tag in one include and its closing[[/div]]in another) that must be visible to the parser as a single continuous text.The resolution process:
[[include page | var=val]]patterns{$key}->value)[[include ...]]directive with the expanded textSafety features include circular dependency detection (using a trace of visited pages) and a configurable maximum recursion depth (default: 5).