resources: Collapse all jQuery UI modules into one deprecated mega-module
[lhc/web/wiklou.git] / maintenance / parse.php
index cf2fe54..43bbca1 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use MediaWiki\MediaWikiServices;
+
 /**
  * Parse some wikitext.
  *
@@ -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,