diff options
author | Subramanya Sastry <ssastry@wikimedia.org> | 2025-01-03 14:42:02 -0600 |
---|---|---|
committer | Subramanya Sastry <ssastry@wikimedia.org> | 2025-01-17 08:38:15 -0600 |
commit | b727f290f5ea827b9b2d9820fb4007bbf29101c4 (patch) | |
tree | 4ae1b30637c52c8a8b2aba5ce3e7b4ca63e89c2c /includes/MainConfigNames.php | |
parent | 56590fc471aef3920d93d556d371cef4bca33a7f (diff) | |
download | mediawikicore-b727f290f5ea827b9b2d9820fb4007bbf29101c4.tar.gz mediawikicore-b727f290f5ea827b9b2d9820fb4007bbf29101c4.zip |
For Parsoid calls, treat preprocessing as starting in SOL state
* If Parsoid calls the preprocessor, initialize lineStart to true.
Track this through:
- parser function calls that return expandable template messages
int: parser function is an example in core
Extensions seem to define a number of other such parser functions
- template-arg substitions
So {{templatename|mytemplate}} with text {{{{{1}}}}} which
is effectively a call to {{mytemplate}} continues to set sol-state
to true across the expansion.
See test "Preprocessor precedence 5: tplarg takes precedence over template"
in preprocessor.txt which exercises this use case.
- However, note that this is a best-faith effort because this flag is
set while building the preprocessor DOM tree before templates are
expanded. So, this is mostly a source syntax flag and constructs
that expand to empty strings can blind the preprocessor to the true
value of SOL state in the expanded string. This is true for both
the legacy parser and Parsoid, and as such T2529 behavior is a hack
with a set of associated edge cases.
* Parsoid models templates as independent documents as always starting
in start-of-line state (and does some patch up for b/c reasons where
this assumption fails). So, there is no reason to add newlines for
some set of wikitext characters (per T2529) when Parsoid is involved.
* This lets us eliminate some hacks in Parsoid to strip these added newlines
when Parsoid was already in SOL state but which then introduces edge cases.
See discussion in T382464 where Parsoid currently cannot distinguish
between a couple of test cases.
* But, with this change, where Parsoid no longer gets a newline added,
Parsoid doesn't have to heuristically remove the newline (and
incorrectly as in the edge case in the bug report) which eliminates
the edge case from the bug report.
* This change has to be backed by a change in Parsoid to undo the T2529
newline removal hack in TokenStreamPatcher to ensure Parsoid CI
doesn't break with this change.
* To let us safely test this in Parsoid's round-trip testing and safely
(and conservatively) roll this out to production, this change is
backed by a new config flag (ParsoidTemplateExpansionMode) which
defaults to false.
We unconditionally set this to true in the ParserTestRunner for all
parser tests.
This flag will be removed once we roll out this change and the
Parsoid change to production.
Bug: T382464
Change-Id: I194a9550500bf7ece215791c51d6feb78a80b1a8
Diffstat (limited to 'includes/MainConfigNames.php')
-rw-r--r-- | includes/MainConfigNames.php | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/includes/MainConfigNames.php b/includes/MainConfigNames.php index e8b357409113..b17fc0f55d04 100644 --- a/includes/MainConfigNames.php +++ b/includes/MainConfigNames.php @@ -2371,6 +2371,12 @@ class MainConfigNames { public const ParsoidFragmentSupport = 'ParsoidFragmentSupport'; /** + * Name constant for the ParsoidNewTemplateExpansionMode setting, for use with Config::get() + * @see MainConfigSchema::ParsoidNewTemplateExpansionMode + */ + public const ParsoidNewTemplateExpansionMode = 'ParsoidNewTemplateExpansionMode'; + + /** * Name constant for the ParserEnableLegacyMediaDOM setting, for use with Config::get() * @see MainConfigSchema::ParserEnableLegacyMediaDOM * @deprecated since 1.41 |