Remove ParserOutput::getText() calls from core (direct pipeline)
This is the second patch of a series of patches to remove ParserOutput::getText() calls from core. This series of patches should be functionally equivalent to I2b4bcddb234f10fd8592570cb0496adf3271328e. This patch replaces the calls to getText where the legacy parser is called directly by creating a pipeline and invoking it on the generated. These should probably eventually use the Content framework to generate output instead of using Parser directly (T371008), which will also allow them to transparently support Parsoid. Bug: T293512 Change-Id: I45951a49e57a8031887ee6e4546335141d231c18
This commit is contained in:
parent
8220113a16
commit
a3cf629d2f
13 changed files with 114 additions and 68 deletions
|
|
@ -2380,12 +2380,19 @@ class OutputPage extends ContextSource {
|
|||
// Add default options from the skin
|
||||
$skin = $this->getSkin();
|
||||
$skinOptions = $skin->getOptions();
|
||||
$oldText = $parserOutput->getRawText();
|
||||
$poOptions += [
|
||||
'suppressClone' => true, // T371022
|
||||
'skin' => $skin,
|
||||
'injectTOC' => $skinOptions['toc'],
|
||||
];
|
||||
// Note: this path absolutely expects $parserOutput to be mutated by getText, see T353257
|
||||
return $parserOutput->getText( $poOptions );
|
||||
$pipeline = MediaWikiServices::getInstance()->getDefaultOutputPipeline();
|
||||
// Note: this path absolutely expects the metadata of $parserOutput to be mutated by the pipeline,
|
||||
// but the raw text should not be, see T353257
|
||||
// TODO T371008 consider if using the Content framework makes sense instead of creating the pipeline
|
||||
$text = $pipeline->run( $parserOutput, $this->parserOptions(), $poOptions )->getContentHolderText();
|
||||
$parserOutput->setRawText( $oldText );
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2394,7 +2401,7 @@ class OutputPage extends ContextSource {
|
|||
*
|
||||
* @since 1.24
|
||||
* @param ParserOutput $parserOutput
|
||||
* @param array $poOptions Options to ParserOutput::getText()
|
||||
* @param array $poOptions Options to OutputTransformPipeline::run() (to be deprecated)
|
||||
*/
|
||||
public function addParserOutputContent( ParserOutput $parserOutput, $poOptions = [] ) {
|
||||
$text = $this->getParserOutputText( $parserOutput, $poOptions );
|
||||
|
|
@ -2411,7 +2418,7 @@ class OutputPage extends ContextSource {
|
|||
*
|
||||
* @internal For local use only
|
||||
* @param string|ParserOutput $text
|
||||
* @param array $poOptions Options to ParserOutput::getText()
|
||||
* @param array $poOptions Options to OutputTransformPipeline::run() (to be deprecated)
|
||||
*/
|
||||
public function addParserOutputText( $text, $poOptions = [] ) {
|
||||
if ( $text instanceof ParserOutput ) {
|
||||
|
|
@ -2426,7 +2433,7 @@ class OutputPage extends ContextSource {
|
|||
* Add everything from a ParserOutput object.
|
||||
*
|
||||
* @param ParserOutput $parserOutput
|
||||
* @param array $poOptions Options to ParserOutput::getText()
|
||||
* @param array $poOptions Options to OutputTransformPipeline::run() (to be deprecated)
|
||||
*/
|
||||
public function addParserOutput( ParserOutput $parserOutput, $poOptions = [] ) {
|
||||
$text = $this->getParserOutputText( $parserOutput, $poOptions );
|
||||
|
|
@ -2458,14 +2465,17 @@ class OutputPage extends ContextSource {
|
|||
if ( $title === null ) {
|
||||
throw new RuntimeException( 'No title in ' . __METHOD__ );
|
||||
}
|
||||
return $this->parseInternal(
|
||||
$po = $this->parseInternal(
|
||||
$text, $title, $linestart, /*interface*/false
|
||||
)->getText( [
|
||||
);
|
||||
$pipeline = MediaWikiServices::getInstance()->getDefaultOutputPipeline();
|
||||
// TODO T371008 consider if using the Content framework makes sense instead of creating the pipeline
|
||||
return $pipeline->run( $po, $this->parserOptions(), [
|
||||
'allowTOC' => false,
|
||||
'enableSectionEditLinks' => false,
|
||||
'wrapperDivClass' => '',
|
||||
'userLang' => $this->getContext()->getLanguage(),
|
||||
] );
|
||||
] )->getContentHolderText();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2484,14 +2494,17 @@ class OutputPage extends ContextSource {
|
|||
if ( $title === null ) {
|
||||
throw new RuntimeException( 'No title in ' . __METHOD__ );
|
||||
}
|
||||
return $this->parseInternal(
|
||||
$po = $this->parseInternal(
|
||||
$text, $title, $linestart, /*interface*/true
|
||||
)->getText( [
|
||||
);
|
||||
$pipeline = MediaWikiServices::getInstance()->getDefaultOutputPipeline();
|
||||
// TODO T371008 consider if using the Content framework makes sense instead of creating the pipeline
|
||||
return $pipeline->run( $po, $this->parserOptions(), [
|
||||
'allowTOC' => false,
|
||||
'enableSectionEditLinks' => false,
|
||||
'wrapperDivClass' => '',
|
||||
'userLang' => $this->getContext()->getLanguage(),
|
||||
] );
|
||||
] )->getContentHolderText();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -809,10 +809,12 @@ abstract class Installer {
|
|||
|
||||
try {
|
||||
$out = $parser->parse( $text, $this->parserTitle, $this->parserOptions, $lineStart );
|
||||
$html = $out->getText( [
|
||||
$pipeline = MediaWikiServices::getInstance()->getDefaultOutputPipeline();
|
||||
// TODO T371008 consider if using the Content framework makes sense instead of creating the pipeline
|
||||
$html = $pipeline->run( $out, $this->parserOptions, [
|
||||
'enableSectionEditLinks' => false,
|
||||
'unwrap' => true,
|
||||
] );
|
||||
] )->getContentHolderText();
|
||||
$html = Parser::stripOuterParagraph( $html );
|
||||
} catch ( ServiceDisabledException $e ) {
|
||||
$html = '<!--DB access attempted during parse--> ' . htmlspecialchars( $text );
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ namespace MediaWiki\Specials;
|
|||
use MediaWiki\Html\Html;
|
||||
use MediaWiki\HTMLForm\HTMLForm;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Output\OutputPage;
|
||||
use MediaWiki\Parser\Parser;
|
||||
use MediaWiki\Parser\ParserOutput;
|
||||
|
|
@ -133,9 +134,10 @@ class SpecialExpandTemplates extends SpecialPage {
|
|||
$out->addHTML( $tmp );
|
||||
|
||||
$pout = $parser->parse( $output, $title, $options );
|
||||
$rawhtml = $pout->getText( [ 'enableSectionEditLinks' => false ] );
|
||||
// TODO T371008 consider if using the Content framework makes sense instead of creating the pipeline
|
||||
$rawhtml = MediaWikiServices::getInstance()->getDefaultOutputPipeline()
|
||||
->run( $pout, $options, [ 'enableSectionEditLinks' => false ] )->getContentHolderText();
|
||||
if ( $generateRawHtml && strlen( $rawhtml ) > 0 ) {
|
||||
// @phan-suppress-next-line SecurityCheck-DoubleEscaped Wanted here to display the html
|
||||
$out->addHTML( $this->makeOutput( $rawhtml, 'expand_templates_html_output' ) );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
use MediaWiki\Config\ServiceOptions;
|
||||
use MediaWiki\Content\TextContent;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Parser\ParserOutput;
|
||||
use MediaWiki\Rest\Handler\Helper\PageRestHelperFactory;
|
||||
use MediaWiki\Revision\SlotRecord;
|
||||
|
|
@ -81,8 +82,8 @@ class CompareLanguageConverterOutput extends Maintenance {
|
|||
$parsoidOutput = $this->getParsoidOutput( $pageTitle, $targetVariant, $user );
|
||||
$converterUsed = $this->getConverterUsed( $parsoidOutput );
|
||||
|
||||
$this->compareOutput( $parserOutput, $parsoidOutput, $converterUsed );
|
||||
|
||||
$this->compareOutput( $parserOutput->getContentHolderText(),
|
||||
$parsoidOutput->getText( [ 'deduplicateStyles' => false ] ), $converterUsed );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +141,11 @@ class CompareLanguageConverterOutput extends Maintenance {
|
|||
->getContent( SlotRecord::MAIN );
|
||||
$wikiContent = ( $content instanceof TextContent ) ? $content->getText() : '';
|
||||
|
||||
return $parser->parse( $wikiContent, $pageTitle, $parserOptions );
|
||||
$po = $parser->parse( $wikiContent, $pageTitle, $parserOptions );
|
||||
// TODO T371008 consider if using the Content framework makes sense instead of creating the pipeline
|
||||
$pipeline = MediaWikiServices::getInstance()->getDefaultOutputPipeline();
|
||||
$options = [ 'deduplicateStyles' => false ];
|
||||
return $pipeline->run( $po, $parserOptions, $options );
|
||||
}
|
||||
|
||||
private function getParsoidOutput(
|
||||
|
|
@ -177,13 +182,10 @@ class CompareLanguageConverterOutput extends Maintenance {
|
|||
}
|
||||
|
||||
private function compareOutput(
|
||||
ParserOutput $parserOutput,
|
||||
ParserOutput $parsoidOutput,
|
||||
string $parserText,
|
||||
string $parsoidText,
|
||||
string $converterUsed
|
||||
): void {
|
||||
$parsoidText = $parsoidOutput->getText( [ 'deduplicateStyles' => false ] );
|
||||
$parserText = $parserOutput->getText( [ 'deduplicateStyles' => false ] );
|
||||
|
||||
$parsoidWords = $this->getWords( $this->getBody( $parsoidText ) );
|
||||
$parserWords = $this->getWords( $parserText );
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,12 @@ class FormatInstallDoc extends Maintenance {
|
|||
$opt = ParserOptions::newFromAnon();
|
||||
$title = Title::newFromText( 'Text file' );
|
||||
$out = $parser->parse( $outText, $title, $opt );
|
||||
$outText = "<html><body>\n" . $out->getText() . "\n</body></html>\n";
|
||||
$outText = "<html><body>\n" .
|
||||
// TODO T371008 consider if using the Content framework makes sense instead of creating the pipeline
|
||||
$this->getServiceContainer()->getDefaultOutputPipeline()
|
||||
->run( $out, $opt, [] )
|
||||
->getContentHolderText()
|
||||
. "\n</body></html>\n";
|
||||
}
|
||||
|
||||
fwrite( $outFile, $outText );
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Parser\ParserOutput;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Title\Title;
|
||||
|
||||
/**
|
||||
|
|
@ -86,7 +86,16 @@ class CLIParser extends Maintenance {
|
|||
* @return string HTML Rendering
|
||||
*/
|
||||
public function render( $wikitext ) {
|
||||
return $this->parse( $wikitext )->getText( [ 'wrapperDivClass' => '' ] );
|
||||
$options = ParserOptions::newFromAnon();
|
||||
$options->setOption( 'enableLimitReport', false );
|
||||
$po = $this->parser->parse(
|
||||
$wikitext,
|
||||
$this->getTitle(),
|
||||
$options
|
||||
);
|
||||
// TODO T371008 consider if using the Content framework makes sense instead of creating the pipeline
|
||||
$pipeline = MediaWikiServices::getInstance()->getDefaultOutputPipeline();
|
||||
return $pipeline->run( $po, $options, [ 'wrapperDivClass' => '' ] )->getContentHolderText();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -127,20 +136,6 @@ class CLIParser extends Maintenance {
|
|||
|
||||
return Title::newFromText( $title );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $wikitext Wikitext to parse
|
||||
* @return ParserOutput
|
||||
*/
|
||||
protected function parse( $wikitext ) {
|
||||
$options = ParserOptions::newFromAnon();
|
||||
$options->setOption( 'enableLimitReport', false );
|
||||
return $this->parser->parse(
|
||||
$wikitext,
|
||||
$this->getTitle(),
|
||||
$options
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$maintClass = CLIParser::class;
|
||||
|
|
|
|||
|
|
@ -1466,11 +1466,14 @@ class ParserTestRunner {
|
|||
if ( isset( $opts['nohtml'] ) ) {
|
||||
$out = '';
|
||||
} else {
|
||||
$out = $output->getText( [
|
||||
// TODO T371008 consider if using the Content framework makes sense instead of creating the pipeline
|
||||
// This may be a case where it may be reasonable to keep accessing the pipeline directly.
|
||||
$pipeline = MediaWikiServices::getInstance()->getDefaultOutputPipeline();
|
||||
$out = $pipeline->run( $output, $options, [
|
||||
'allowTOC' => !isset( $opts['notoc'] ),
|
||||
'unwrap' => !isset( $opts['wrap'] ),
|
||||
'skin' => $this->getSkin( $opts['skin'] ?? 'fallback' ),
|
||||
] );
|
||||
] )->getContentHolderText();
|
||||
$out = rtrim( $out );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1860,7 +1860,7 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertFalse( $op->getOutputFlag( ParserOutputFlags::NEW_SECTION ) );
|
||||
|
||||
$pOut = $this->createParserOutputStubWithFlags( [
|
||||
'getText' => '<some text>',
|
||||
'getContentHolderText' => '<some text>',
|
||||
'getNewSection' => true,
|
||||
], [
|
||||
ParserOutputFlags::NEW_SECTION,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use MediaWiki\Content\IContentHandlerFactory;
|
|||
use MediaWiki\Content\Renderer\ContentRenderer;
|
||||
use MediaWiki\Content\WikitextContent;
|
||||
use MediaWiki\HookContainer\HookContainer;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Page\PageIdentityValue;
|
||||
use MediaWiki\Page\PageReference;
|
||||
use MediaWiki\Parser\ParserOutput;
|
||||
|
|
@ -395,18 +396,20 @@ class RevisionRendererTest extends MediaWikiIntegrationTestCase {
|
|||
$rev->setContent( SlotRecord::MAIN, new WikitextContent( '[[Kittens]]' ) );
|
||||
$rev->setContent( 'aux', new WikitextContent( '[[Goats]]' ) );
|
||||
|
||||
$rr = $renderer->getRenderedRevision( $rev );
|
||||
$options = ParserOptions::newFromAnon();
|
||||
$rr = $renderer->getRenderedRevision( $rev, $options );
|
||||
|
||||
$combinedOutput = $rr->getRevisionParserOutput();
|
||||
$mainOutput = $rr->getSlotParserOutput( SlotRecord::MAIN );
|
||||
$auxOutput = $rr->getSlotParserOutput( 'aux' );
|
||||
|
||||
$combinedHtml = $combinedOutput->getText();
|
||||
$mainHtml = $mainOutput->getText();
|
||||
$pipeline = MediaWikiServices::getInstance()->getDefaultOutputPipeline();
|
||||
$combinedHtml = $pipeline->run( $combinedOutput, $options, [] )->getContentHolderText();
|
||||
$mainHtml = $pipeline->run( $mainOutput, $options, [] )->getContentHolderText();
|
||||
|
||||
$this->assertNotSame( $combinedHtml, $mainHtml );
|
||||
|
||||
$auxHtml = $auxOutput->getText();
|
||||
$auxHtml = $pipeline->run( $auxOutput, $options, [] )->getContentHolderText();
|
||||
|
||||
$this->assertStringContainsString( 'Kittens', $mainHtml );
|
||||
$this->assertStringContainsString( 'Goats', $auxHtml );
|
||||
|
|
@ -447,10 +450,12 @@ class RevisionRendererTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$combinedOutput = $rr->getRevisionParserOutput();
|
||||
$mainOutput = $rr->getSlotParserOutput( SlotRecord::MAIN );
|
||||
$combinedHtml = $combinedOutput->getText();
|
||||
$this->assertSame( $combinedHtml, $mainOutput->getText() );
|
||||
|
||||
$combinedHtml = $pipeline->run( $combinedOutput, $options, [] )->getContentHolderText();
|
||||
$mainHtml = $pipeline->run( $mainOutput, $options, [] )->getContentHolderText();
|
||||
$this->assertSame( $combinedHtml, $mainHtml );
|
||||
$this->assertSame( $combinedOutput->getLinks(), $mainOutput->getLinks() );
|
||||
$this->assertStringContainsString( 'class="mw-content-ltr mw-parser-output"', $combinedHtml );
|
||||
$this->assertStringContainsString( 'class="mw-content-ltr mw-parser-output"', $mainHtml );
|
||||
$this->assertStringContainsString( 'Kittens', $combinedHtml );
|
||||
$this->assertStringNotContainsString( 'Goats', $combinedHtml );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use MediaWiki\Json\JsonCodec;
|
|||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\Logger\Spi as LoggerSpi;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Page\Hook\OpportunisticLinksUpdateHook;
|
||||
use MediaWiki\Page\PageRecord;
|
||||
use MediaWiki\Page\ParserOutputAccess;
|
||||
|
|
@ -56,7 +57,8 @@ class ParserOutputAccessTest extends MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
if ( $value instanceof ParserOutput ) {
|
||||
$value = $value->getText();
|
||||
$pipeline = MediaWikiServices::getInstance()->getDefaultOutputPipeline();
|
||||
$value = $pipeline->run( $value, $this->getParserOptions(), [] )->getContentHolderText();
|
||||
}
|
||||
|
||||
$html = preg_replace( '/<!--.*?-->/s', '', $value );
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use MediaWiki\Content\WikitextContent;
|
|||
use MediaWiki\Deferred\SiteStatsUpdate;
|
||||
use MediaWiki\Edit\PreparedEdit;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Parser\ParserOutput;
|
||||
use MediaWiki\Permissions\Authority;
|
||||
use MediaWiki\Revision\MutableRevisionRecord;
|
||||
|
|
@ -941,7 +942,8 @@ class WikiPageDbTest extends MediaWikiLangTestCase {
|
|||
|
||||
$opt = $page->makeParserOptions( 'canonical' );
|
||||
$po = $page->getParserOutput( $opt );
|
||||
$text = $po->getText();
|
||||
$pipeline = MediaWikiServices::getInstance()->getDefaultOutputPipeline();
|
||||
$text = $pipeline->run( $po, $opt, [] )->getContentHolderText();
|
||||
|
||||
$text = trim( preg_replace( '/<!--.*?-->/sm', '', $text ) ); # strip injected comments
|
||||
$text = preg_replace( '!\s*(</p>|</div>)!m', '\1', $text ); # don't let tidy confuse us
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use LogicException;
|
|||
use MediaWiki\Context\RequestContext;
|
||||
use MediaWiki\Debug\MWDebug;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Parser\ParserOutput;
|
||||
use MediaWiki\Parser\ParserOutputFlags;
|
||||
use MediaWiki\Parser\ParserOutputStringSets;
|
||||
|
|
@ -265,6 +266,8 @@ class ParserOutputTest extends MediaWikiLangTestCase {
|
|||
*/
|
||||
public function testWrapperDivClass() {
|
||||
$po = new ParserOutput();
|
||||
$opts = ParserOptions::newFromAnon();
|
||||
$pipeline = MediaWikiServices::getInstance()->getDefaultOutputPipeline();
|
||||
|
||||
$po->setRawText( 'Kittens' );
|
||||
$this->assertStringContainsString( 'Kittens', $po->getText() );
|
||||
|
|
@ -272,29 +275,29 @@ class ParserOutputTest extends MediaWikiLangTestCase {
|
|||
$this->assertSame( 'Kittens', $po->getRawText() );
|
||||
|
||||
$po->addWrapperDivClass( 'foo' );
|
||||
$text = $po->getText();
|
||||
$text = $pipeline->run( $po, $opts, [] )->getContentHolderText();
|
||||
$this->assertStringContainsString( 'Kittens', $text );
|
||||
$this->assertStringContainsString( '<div', $text );
|
||||
$this->assertStringContainsString( 'class="mw-content-ltr foo"', $text );
|
||||
|
||||
$po->addWrapperDivClass( 'bar' );
|
||||
$text = $po->getText();
|
||||
$text = $pipeline->run( $po, $opts, [] )->getContentHolderText();
|
||||
$this->assertStringContainsString( 'Kittens', $text );
|
||||
$this->assertStringContainsString( '<div', $text );
|
||||
$this->assertStringContainsString( 'class="mw-content-ltr foo bar"', $text );
|
||||
|
||||
$po->addWrapperDivClass( 'bar' ); // second time does nothing, no "foo bar bar".
|
||||
$text = $po->getText( [ 'unwrap' => true ] );
|
||||
$text = $pipeline->run( $po, $opts, [ 'unwrap' => true ] )->getContentHolderText();
|
||||
$this->assertStringContainsString( 'Kittens', $text );
|
||||
$this->assertStringNotContainsString( '<div', $text );
|
||||
$this->assertStringNotContainsString( 'class="', $text );
|
||||
|
||||
$text = $po->getText( [ 'wrapperDivClass' => '' ] );
|
||||
$text = $pipeline->run( $po, $opts, [ 'wrapperDivClass' => '' ] )->getContentHolderText();
|
||||
$this->assertStringContainsString( 'Kittens', $text );
|
||||
$this->assertStringNotContainsString( '<div', $text );
|
||||
$this->assertStringNotContainsString( 'class="', $text );
|
||||
|
||||
$text = $po->getText( [ 'wrapperDivClass' => 'xyzzy' ] );
|
||||
$text = $pipeline->run( $po, $opts, [ 'wrapperDivClass' => 'xyzzy' ] )->getContentHolderText();
|
||||
$this->assertStringContainsString( 'Kittens', $text );
|
||||
$this->assertStringContainsString( '<div', $text );
|
||||
$this->assertStringContainsString( 'class="mw-content-ltr xyzzy"', $text );
|
||||
|
|
@ -304,7 +307,7 @@ class ParserOutputTest extends MediaWikiLangTestCase {
|
|||
$this->assertSame( 'Kittens', $text );
|
||||
|
||||
$po->clearWrapperDivClass();
|
||||
$text = $po->getText();
|
||||
$text = $pipeline->run( $po, $opts, [] )->getContentHolderText();
|
||||
$this->assertStringContainsString( 'Kittens', $text );
|
||||
$this->assertStringNotContainsString( '<div', $text );
|
||||
$this->assertStringNotContainsString( 'class="', $text );
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace MediaWiki\Tests\Parser\Parsoid;
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Parser\Parsoid\ParsoidParser;
|
||||
use MediaWiki\Title\Title;
|
||||
use MediaWikiIntegrationTestCase;
|
||||
|
|
@ -26,21 +27,26 @@ class ParsoidParserTest extends MediaWikiIntegrationTestCase {
|
|||
$args[2] = ParserOptions::newFromAnon();
|
||||
}
|
||||
$output = $parsoidParser->parse( ...$args );
|
||||
$html = $output->getText( $getTextOpts );
|
||||
$html = $output->getRawText();
|
||||
$this->assertStringContainsString( $expected, $html );
|
||||
$this->assertSame(
|
||||
$args[1]->getPrefixedDBkey(),
|
||||
$output->getExtensionData( ParsoidParser::PARSOID_TITLE_KEY )
|
||||
);
|
||||
$this->assertArrayEquals( [
|
||||
$usedOptions = [
|
||||
'collapsibleSections',
|
||||
'disableContentConversion',
|
||||
'interfaceMessage',
|
||||
'wrapclass',
|
||||
'suppressSectionEditLinks',
|
||||
'isPreview',
|
||||
'maxIncludeSize',
|
||||
'collapsibleSections',
|
||||
], $output->getUsedOptions() );
|
||||
'suppressSectionEditLinks',
|
||||
'wrapclass',
|
||||
];
|
||||
$this->assertEqualsCanonicalizing( $usedOptions, $output->getUsedOptions() );
|
||||
|
||||
$pipeline = MediaWikiServices::getInstance()->getDefaultOutputPipeline();
|
||||
$pipeline->run( $output, $args[2], [] );
|
||||
$this->assertArrayEquals( $usedOptions, $output->getUsedOptions() );
|
||||
}
|
||||
|
||||
public static function provideParsoidParserHtml() {
|
||||
|
|
@ -61,21 +67,22 @@ class ParsoidParserTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$parsoidParser = $this->getServiceContainer()
|
||||
->getParsoidParserFactory()->create();
|
||||
$opts = ParserOptions::newFromAnon();
|
||||
$output = $parsoidParser->parse(
|
||||
$helloWorld,
|
||||
$pageTitle,
|
||||
ParserOptions::newFromAnon(),
|
||||
$opts,
|
||||
true,
|
||||
true,
|
||||
$page->getRevisionRecord()->getId()
|
||||
);
|
||||
$html = $output->getText();
|
||||
$html = $output->getRawText();
|
||||
$this->assertStringContainsString( $helloWorld, $html );
|
||||
$this->assertSame(
|
||||
$pageTitle->getPrefixedDBkey(),
|
||||
$output->getExtensionData( ParsoidParser::PARSOID_TITLE_KEY )
|
||||
);
|
||||
$this->assertArrayEquals( [
|
||||
$usedOptions = [
|
||||
'collapsibleSections',
|
||||
'disableContentConversion',
|
||||
'interfaceMessage',
|
||||
|
|
@ -83,6 +90,11 @@ class ParsoidParserTest extends MediaWikiIntegrationTestCase {
|
|||
'maxIncludeSize',
|
||||
'suppressSectionEditLinks',
|
||||
'wrapclass',
|
||||
], $output->getUsedOptions() );
|
||||
];
|
||||
$this->assertArrayEquals( $usedOptions, $output->getUsedOptions() );
|
||||
|
||||
$pipeline = MediaWikiServices::getInstance()->getDefaultOutputPipeline();
|
||||
$pipeline->run( $output, $opts, [] );
|
||||
$this->assertArrayEquals( $usedOptions, $output->getUsedOptions() );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue