aboutsummaryrefslogtreecommitdiffstats
path: root/includes/OutputTransform
Commit message (Collapse)AuthorAgeFilesLines
...
* | ExtractBody: Convert page-internal link fragments to pure fragment urlsSubramanya Sastry2024-04-121-7/+25
|/ | | | | | | | | | | | | | | | | | | | | | * This ensures that when you have query params like (?useparsoid=1), all cite links no longer take you to the non-Parsoid page but resolve internally. * Additionally, this also unbreaks reference previews in local testing - not yet sure if this will fix all breakage in production. * We don't have ready access to the title string and so this patch extracts it from a link tag in the <head> of Parsoid HTML. That is guaranteed to be correct and reliably present. But, if in the future, this changes (whether by adding it to ParserOptions, ParserOutput, or the $opts array), we can use that directly. * Added new unit tests that verify the new expectations. Bug: T358242 Change-Id: Iaf482cc9803564b4cf4ae04f975573f61ff3b0e4
* Merge "HandleSectionLinks: Remove old debug logging for resolved bug"jenkins-bot2024-03-122-19/+3
|\
| * HandleSectionLinks: Remove old debug logging for resolved bugBartosz Dziewoński2024-03-072-19/+3
| | | | | | | | | | | | | | This is just a cleanup change. The exception should never happen, but if it does, this can be reverted. Change-Id: I26a7c4105d39d83015c09b779a2de3fd1ddacec1
* | Deprecate Linker::generateTOC() and related methodsBartosz Dziewoński2024-03-071-4/+150
|/ | | | | | Move the code to private methods in the only place that needs it. Change-Id: I7aa038e055adc1aea9faafd17b86e304ee2ca758
* Deprecate Linker::makeHeadline()Bartosz Dziewoński2024-03-071-3/+27
| | | | | | Move the code to a private method in the only place that needs it. Change-Id: Ie68a5324b2c789f44ffc495d05eb6957234cb9c8
* HandleSectionLinks: Fix handling headings with raw `>` in attributesBartosz Dziewoński2024-03-041-1/+2
| | | | | | | | | | | | | | | 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
* Don't double-wrap headings when using DiscussionToolsC. Scott Ananian2024-02-171-18/+44
| | | | | | | | | | | | | Discussion Tools runs *before* this stage runs, and so we end up wrapping headings which have already been wrapped by discussion tools. Check for an existing wrapper to avoid this. In the future, we will probably add a new post-cache transform hook which is at the very *end* of the pipeline, instead of in the middle, to avoid this sort of ordering dependency between extensions and core. Bug: T357826 Change-Id: I8cd28a3b42e55844be1258d639e605862952806f
* Move Parser to Mediawiki\Parser namespaceSubramanya Sastry2024-02-162-2/+2
| | | | | | | | Bug: T166010 Co-Authored-By: Daimona Eaytoy <daimona.wiki@gmail.com> Co-Authored-By: James Forrester <jforrester@wikimedia.org> Co-Authored-By: Subramanya Sastry <ssastry@wikimedia.org> Change-Id: I79b4e732c45095eedbaa80afa5eb7479b387ed8a
* Merge "HandleSectionLinks: Remove warning when we don't find attributes"jenkins-bot2024-02-151-6/+1
|\
| * HandleSectionLinks: Remove warning when we don't find attributesBartosz Dziewoński2024-02-151-6/+1
| | | | | | | | | | | | | | | | | | | | I realized that this code path is also triggered by a special page transclusion that outputs headings, e.g. `{{Special:RecentChanges}}`. It doesn't seem worth it to try to handle all these cases distinctly. Follow-up to b26db1f866c1f18d4e12466ccf191e7c65aa870d. Change-Id: I389ea9210fcc184f41b6731409331dbd3d34d2ca
* | [OutputTransform] Add section edit links to Parsoid outputC. Scott Ananian2024-02-152-0/+113
| | | | | | | | | | Bug: T269630 Change-Id: I9d5fb6348609642ad94743cc5dae81ce608be99d
* | [OutputTransform] Remove broken and unused 'bodyContentOnly' optionC. Scott Ananian2024-02-153-14/+8
| | | | | | | | | | | | | | | | | | | | This was formerly used by the REST api, but instead that code just uses ParserOutput::getRawText() when it needs the full HTML document. This option has been broken, with various passes like RenderDebugInfo and AddWrapperDiv adding content in inappropriate places if bodyContentOnly was false. Change-Id: Ib45f95ded59c81c16d61803f977d1edbfe82b262
* | [OutputTransform] Improve ContentDOMTransformStageC. Scott Ananian2024-02-151-2/+55
| | | | | | | | | | | | | | | | | | | | Make ContentDOMTransformStage handle Parsoid markup with PageBundle information embedded in the ParserOutput. Much of the complexity of this code should move to either Parsoid's ContentUtils or else into the HtmlHolder abstraction (T347062). Change-Id: Ib35ae38d84adc7df613d4c7de8930ed80e535634
* | Merge "Namespace Message, move to appropriate directory"jenkins-bot2024-02-151-1/+1
|\ \ | |/ |/|
| * Namespace Message, move to appropriate directoryJames D. Forrester2024-02-141-1/+1
| | | | | | | | | | Bug: T353458 Change-Id: I088cbc53fbcdb974e5b05b45a62e91709dacc024
* | Apply relative attr expansion to indicatorsArlo Breault2024-02-141-10/+16
| | | | | | | | | | Bug: T357573 Change-Id: If80d0df6c927d0f6981ad56d01751f1aeaba83d3
* | Resolve relative resource attributes as wellArlo Breault2024-02-141-4/+12
|/ | | | | | | | | The resource attribute is used in read views for magnify links and imagemap description links. See Id46d1b2ab1af3baebff13e10f1485f3cfd9a4b37 and I20130fd39135dfd5074590ee9c2b6e01693384e4 Bug: T357573 Change-Id: I974701ba9eb77e8d0abc894d1091fcdd63b84684
* Move section heading formatting to post-cache transform (forward-compat)Bartosz Dziewoński2024-02-091-2/+55
| | | | | | | | | Split off from I4eae18d9d16f54391daba0de82ad05e50f07f9eb for forward-compatibility, in case that patch needs to be reverted. See that change for tests and explanation. Bug: T13555 Change-Id: Ibce512b3c4a52f74b2d2124f0159e306f2689ea5
* [ParserOutput] Make 'enableSectionEditLinks' a ParserOptionC. Scott Ananian2024-02-091-1/+5
| | | | | | | | | | | | | | | | | | This will allow the Translate extension to set this parser option in the ArticleParserOptions hook, instead of mutating $options passed to ParserOutput::getText() in the ParserOutputPostCacheTransform hook. It ought to also help to handle the many places which call: ... = $parserOutput->getText( [ 'enableSectionEditLinks' => false, ] ); by allowing them to set the appropriate ParserOption instead of passing arguments to ::getText(). Bug: T350626 Change-Id: I719c115194059060f7f888608417a194ac80cc92
* Namespace includes/contextJames D. Forrester2024-02-082-2/+2
| | | | | Bug: T353458 Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
* Rename PostCacheTransformHookRunnerIsabelle Hurbain-Palatin2024-02-073-4/+4
| | | | | | | Follow-up to I53551ec6d6471569709c71c1155729e550f64de8. Bug: T348253 Change-Id: Ia08624a6770070313bf8bbaa11df29e4ed30b73b
* Fix capitalisation of MediaWiki\OutputTransform namespaceReedy2024-01-0215-35/+35
| | | | | | | | It was using Mediawiki not MediaWiki Follows-Up: Ibc46c34072eadb3e84f69df49a3a424f3864c952 Follows-Up: I53551ec6d6471569709c71c1155729e550f64de8 Change-Id: Ia37a6330d64c3179d7abc12ec3f6fc7daca2e371
* Revert "Use Remex for DeduplicateStyles transform"Isabelle Hurbain-Palatin2023-12-221-20/+15
| | | | | | | | | | | This reverts commit 82da9cf14be08e9458f58fa96be51966a2fe7cb1. Passing through Remex seems to have unexpected consequences to be investigated but, for the sake of unbreaking the UBN, let's revert this first. Bug: T353920 Change-Id: Iaac7942aa77aee5ab525852ac5b41dd516ff13c9
* Fix showing units and limits in NewPP limit reportBartosz Dziewoński2023-12-211-1/+1
| | | | | | | Follow-up to a3f51c732d5d2d24ac205c0855df1e78abafb421. Bug: T353793 Change-Id: I9a3ce95629ca0b75865ec375c9ad5734510952f8
* Use Remex for DeduplicateStyles transformC. Scott Ananian2023-12-151-15/+20
| | | | | | | | | | | | | | | | | | | | | | | | The previous implementation was using an ad-hoc regular expression which was matching inside the data-mw attribute of Parsoid output, eg: <sup about="#mwt42" [...] typeof="mw:Extension/ref mw:Error" data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;attrs&quot;:{&quot;name&quot;:&quot;infobox_stats_ref_rail&quot;},&quot;body&quot;:{&quot;html&quot;:&quot;<style data-mw-deduplicate=\&quot;TemplateStyles:r1133582631\&quot; typeof=\&quot;..."> After substitution, the <link> element inserted contained " instead of &quot; and so broke out of the attribute. Instead use a proper HTML tokenizer (via wikimedia/remex-html) so that we don't allow bogus matches inside attribute values. To fix up tests: * Don't deduplicate styles when parsing UX messages (also helps performance) * Don't deduplicate styles in ContentHandler integration tests * Don't deduplicate styles by default in parser tests (unless explicit option is set) Depends-On: Id9801a9ff540bd818a32bc6fa35c48a9cff12d3a Depends-On: I5111f1fdb7140948b82113adbc774af286174ab3 Followup-To: Ic0b17e361bf6eb0e71c498abc17f5f67f82318f8 Change-Id: I32d3d1772243c3819e1e1486351d16871b6e21c4
* Namespace ParserOutputJames D. Forrester2023-12-1414-14/+14
| | | | | | | Most used non-namespaced class! Bug: T353458 Change-Id: I4c2cbb0a808b3881a4d6ca489eee5d8c8ebf26cf
* ParserOutput::getText(): do not clone ParserOutput when invoking pipelineIsabelle Hurbain-Palatin2023-12-121-3/+12
| | | | | | | | | | | | | | | | | OutputPage::getParserOutputText/addParserOutputContent expects ParserOutput to be mutated (e.g. by PostCacheTransformHookRunner). Hence, cloning it before running the pipeline is breaking DiscussionTools, probably among others. Suppress the clone for the case where the output pipeline is invoked from ParserOutput::getText() (which is a deprecated method anyway) and additionally suppress the side-effects to ParserOutput::$mText on that code path. Bug: T353257 Co-Authored-By: C. Scott Ananian <cananian@wikimedia.org> Co-Authored-By: Isabelle Hurbain-Palatin <ihurbainpalatin@wikimedia.org> Change-Id: I85c690fd37b781cb27c21970467639e852113b2a
* Use namespaced classesUmherirrender2023-12-115-8/+8
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statements and changes to docs done manually Change-Id: I443aada1c18c8628b02671aa9fd6f441961e5c2e
* Introduce ContentDOMTransformStageIsabelle Hurbain-Palatin2023-12-081-0/+31
| | | | | | | | | This subclass is used for transformations that apply to the DOM tree. For now, we load the document from the string in ParserOutput and store it back; ultimately, this will be replaced by a direct access to the DOM content of the ContentHolder/HtmlHolder. Change-Id: Ibc46c34072eadb3e84f69df49a3a424f3864c952
* Refactor DefaultOutputTransform into a pipeline of transformsIsabelle Hurbain-Palatin2023-12-0815-0/+732
Bug: T348253 Change-Id: I53551ec6d6471569709c71c1155729e550f64de8