In the JavaScript and CSS content handlers we render the page "as wikitext" solely to generate categories, toc, etc, and then throw that output away and replace the generated HTML. Simplify the code paths and the caching by using the canonical options which don't split by user language, etc. Three minor issues with the current patch, which can hopefully be addressed in follow ups: 1. WikiPage::makeParserOptionsFromTitleAndModel() has a very cumbersome name and arguably doesn't belong in WikiPage in the first place. T313455 already exists to find a better place for this/way to do this. 2. Title::isConversionTable() requires a downcast of the page reference to a full title object. This method also probably wants to live somewhere else. 3. It really would be nice to combine this more properly with ContentHandler::getParserOutputForIndexing(), but that method uses a ParserOutputAccess object which requires a PageRecord, and we don't have a PageRecord available in fillParserOutput(). Bug: T307691 Change-Id: I081105741b507ed49e19cb878550ba4293e09413
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group ContentHandler
|
|
* @group Database
|
|
* ^--- needed, because we do need the database to test link updates
|
|
*/
|
|
class CssContentHandlerIntegrationTest extends TextContentHandlerIntegrationTest {
|
|
public static function provideGetParserOutput() {
|
|
yield 'Basic render' => [
|
|
'title' => 'MediaWiki:Test.css',
|
|
'model' => null,
|
|
'text' => "hello <world>x\n",
|
|
'expectedHtml' => "<pre class=\"mw-code mw-css\" dir=\"ltr\">\nhello <world>x\n\n</pre>",
|
|
'expectedFields' => [
|
|
'Links' => [
|
|
],
|
|
'Sections' => [
|
|
],
|
|
],
|
|
];
|
|
yield 'Links' => [
|
|
'title' => 'MediaWiki:Test.css',
|
|
'model' => null,
|
|
'text' => "/* hello [[world]] */\n",
|
|
'expectedHtml' => "<pre class=\"mw-code mw-css\" dir=\"ltr\">\n/* hello [[world]] */\n\n</pre>",
|
|
'expectedFields' => [
|
|
'Links' => [
|
|
[ 'World' => 0, ],
|
|
],
|
|
'Sections' => [
|
|
],
|
|
],
|
|
];
|
|
yield 'TOC' => [
|
|
'title' => 'MediaWiki:Test.css',
|
|
'model' => null,
|
|
'text' => "==One==\n<h2>Two</h2>",
|
|
'expectedHtml' => "<pre class=\"mw-code mw-css\" dir=\"ltr\">\n==One==\n<h2>Two</h2>\n</pre>",
|
|
'expectedFields' => [
|
|
'Links' => [
|
|
],
|
|
# T307691
|
|
'Sections' => [
|
|
],
|
|
]
|
|
];
|
|
}
|
|
}
|