Commit graph

10 commits

Author SHA1 Message Date
Bartosz Dziewoński
0d99a1c445 HandleSectionLinks: Remove old debug logging for resolved bug
This is just a cleanup change. The exception should never happen,
but if it does, this can be reverted.

Change-Id: I26a7c4105d39d83015c09b779a2de3fd1ddacec1
2024-03-07 23:09:25 +01:00
Bartosz Dziewoński
c50d43ff65 HandleSectionLinks: Fix handling headings with raw > in attributes
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
2024-03-04 21:28:44 +01:00
jenkins-bot
a3fa07e4d4 Merge "Move section heading formatting to post-cache transform (take 2)" 2024-02-23 05:15:21 +00:00
Bartosz Dziewoński
834ff25dc1 Move section heading formatting to post-cache transform (take 2)
[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
2024-02-16 20:28:56 +00:00
Reedy
e94e265a93 tests: Add Tests to PHP namespacing
Change-Id: I849268172751d50292e93aa75abe8094873f56bc
2024-02-16 19:10:11 +00:00
C. Scott Ananian
e72e1cd163 Revert "Move section heading formatting to post-cache transform"
This reverts commit de0646843a.

Reason for revert: caused T357723.

Change-Id: I4690c03a34e8796090563e19a214d8ede63fe5d1
2024-02-15 20:58:32 +00:00
Bartosz Dziewoński
de0646843a Move section heading formatting to post-cache transform
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
2024-02-15 13:09:08 -05:00
Aaron Schulz
f4261e029f Clean up MediaWiki\OutputTransform namespace casing confusion
The case mismatch was causing confusing PHP errors about missing
classes during paratest runs.

Change-Id: Iaddddd2ff825e41609e915938bc27c0bc4bba245
2024-01-05 17:53:19 -08:00
James D. Forrester
9bfb75ff90 Namespace ParserOutput
Most used non-namespaced class!

Bug: T353458
Change-Id: I4c2cbb0a808b3881a4d6ca489eee5d8c8ebf26cf
2023-12-14 14:57:34 -05:00
Isabelle Hurbain-Palatin
a3f51c732d Refactor DefaultOutputTransform into a pipeline of transforms
Bug: T348253
Change-Id: I53551ec6d6471569709c71c1155729e550f64de8
2023-12-08 18:06:19 -05:00