This is just a cleanup change. The exception should never happen,
but if it does, this can be reverted.
Change-Id: I26a7c4105d39d83015c09b779a2de3fd1ddacec1
Follow-up to Ibce512b3c4a52f74b2d2124f0159e306f2689ea5.
HEADING_REGEX will now correctly match opening tags when one of the
attributes contains an unencoded > character.
In a better world, this would not use regular expressions. However,
while implementing it as a DOM transformation is easy enough, doing so
causes never-ending test failures due to changes in HTML serialization,
so we gave up on it for now in after discussion on the original patch.
Bug: T358810
Change-Id: Ibad4b29a988c2a4911ebe6512791042c46dd1a9b
[Previously attempted in de0646843a,
reverted in e72e1cd16368346b66853f68e2d13f9b416d5a11.]
Previously, Parser.php used Linker::makeHeadline() in order to
generate the `<h2><span class="mw-headline" id="...">...</span></h2>`
markup for section headings, and this was saved in the parser cache.
Now it generates heading tags with placeholder attributes like
`<h2 data-mw-...="..." ...>...</h2>`, and they are replaced in a
post-cache transform to generate the final heading markup, similarly
to how section edit links already worked.
The purpose of these changes is to allow changing the final markup
depending on skin options without splitting the parser cache (T13555).
Deployment and undeployment safety:
* The new post-cache transform has been already added in commit
Ibce512b3c4a52f74b2d2124f0159e306f2689ea5 for forward-compatibility
(so that if this patch is reverted, new parser cache entries
will still be shown correctly).
Implementation notes:
* There are many ways to keep the temporary information other than
`data-mw-...` attributes, but this way is the easiest to handle
in a post-cache transform (everything is on the DOM node we want
to modify), is compatible with other heading-enhancing code in
DiscussionTools and MobileFrontend, and remains human-readable
if the post-cache transform doesn't run.
* Sadly this code can't be reused to add section heading markup and
section edit links to Parsoid (T269630), because it lacks some of
the necessary metadata, and exposes the rest in ways that are
trickier to handle in a post-cache transform (on other DOM nodes
or outside the document).
Depends-On: If85f89c40834618f23dc0ace2e599efb3b6d5ed4
Bug: T13555
Change-Id: If04d72f427ec3c3730e757cbb3ade8840c09f7d3
Previously, Parser.php used Linker::makeHeadline() in order to
generate the `<h2><span class="mw-headline" id="...">...</span></h2>`
markup for section headings, and this was saved in the parser cache.
Now it generates heading tags with placeholder attributes like
`<h2 data-mw-...="..." ...>...</h2>`, and they are replaced in a
post-cache transform to generate the final heading markup, similarly
to how section edit links already worked.
The purpose of these changes is to allow changing the final markup
depending on skin options without splitting the parser cache (T13555).
Deployment and undeployment safety:
* The new post-cache transform has been already added in commit
Ibce512b3c4a52f74b2d2124f0159e306f2689ea5 for forward-compatibility
(so that if this patch is reverted, new parser cache entries
will still be shown correctly).
Implementation notes:
* There are many ways to keep the temporary information other than
`data-mw-...` attributes, but this way is the easiest to handle
in a post-cache transform (everything is on the DOM node we want
to modify), is compatible with other heading-enhancing code in
DiscussionTools and MobileFrontend, and remains human-readable
if the post-cache transform doesn't run.
* Sadly this code can't be reused to add section heading markup and
section edit links to Parsoid (T269630), because it lacks some of
the necessary metadata, and exposes the rest in ways that are
trickier to handle in a post-cache transform (on other DOM nodes
or outside the document).
Bug: T13555
Change-Id: I4eae18d9d16f54391daba0de82ad05e50f07f9eb