X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Fparse.php;h=43bbca1177864055e44958be09a4ff4f95b85d55;hb=efbfa0a727a196e63a2b71f0a82f09150c2be354;hp=6279a348ac7de78b17905a3fa5db55325f9be4c7;hpb=f7668403e0218e05dadfd7e0efed63bcb7953b7a;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/parse.php b/maintenance/parse.php index 6279a348ac..43bbca1177 100644 --- a/maintenance/parse.php +++ b/maintenance/parse.php @@ -1,4 +1,7 @@ - * @license GNU General Public License 2.0 or later + * @license GPL-2.0-or-later */ require_once __DIR__ . '/Maintenance.php'; @@ -68,7 +71,7 @@ class CLIParser extends Maintenance { false, true ); - $this->addOption( 'tidy', 'Tidy the output' ); + $this->addOption( 'no-tidy', 'Don\'t tidy the output (deprecated)' ); $this->addArg( 'file', 'File containing wikitext (Default: stdin)', false ); } @@ -82,7 +85,7 @@ class CLIParser extends Maintenance { * @return string HTML Rendering */ public function render( $wikitext ) { - return $this->parse( $wikitext )->getText(); + return $this->parse( $wikitext )->getText( [ 'wrapperDivClass' => '' ] ); } /** @@ -103,9 +106,7 @@ class CLIParser extends Maintenance { } protected function initParser() { - global $wgParserConf; - $parserClass = $wgParserConf['class']; - $this->parser = new $parserClass(); + $this->parser = MediaWikiServices::getInstance()->getParserFactory()->create(); } /** @@ -116,9 +117,7 @@ class CLIParser extends Maintenance { * @return Title */ protected function getTitle() { - $title = $this->getOption( 'title' ) - ? $this->getOption( 'title' ) - : 'CLIParser'; + $title = $this->getOption( 'title' ) ?: 'CLIParser'; return Title::newFromText( $title ); } @@ -128,9 +127,10 @@ class CLIParser extends Maintenance { * @return ParserOutput */ protected function parse( $wikitext ) { - $options = new ParserOptions; - if ( $this->getOption( 'tidy' ) ) { - $options->setTidy( true ); + $options = ParserOptions::newCanonical(); + $options->setOption( 'enableLimitReport', false ); + if ( $this->getOption( 'no-tidy' ) ) { + $options->setTidy( false ); } return $this->parser->parse( $wikitext, @@ -140,5 +140,5 @@ class CLIParser extends Maintenance { } } -$maintClass = "CLIParser"; +$maintClass = CLIParser::class; require_once RUN_MAINTENANCE_IF_MAIN;