Add --tidy option to maintenance/parse.php
authorSubramanya Sastry <ssastry@wikimedia.org>
Sun, 12 Mar 2017 22:13:51 +0000 (17:13 -0500)
committerTim Starling <tstarling@wikimedia.org>
Tue, 14 Mar 2017 22:49:02 +0000 (09:49 +1100)
Change-Id: I6ec08237bd15ee2d824164a0493b7fff9ef312db

maintenance/parse.php

index 17a8d2e..6279a34 100644 (file)
@@ -68,6 +68,7 @@ class CLIParser extends Maintenance {
                        false,
                        true
                );
+               $this->addOption( 'tidy', 'Tidy the output' );
                $this->addArg( 'file', 'File containing wikitext (Default: stdin)', false );
        }
 
@@ -127,10 +128,14 @@ class CLIParser extends Maintenance {
         * @return ParserOutput
         */
        protected function parse( $wikitext ) {
+               $options = new ParserOptions;
+               if ( $this->getOption( 'tidy' ) ) {
+                       $options->setTidy( true );
+               }
                return $this->parser->parse(
                        $wikitext,
                        $this->getTitle(),
-                       new ParserOptions()
+                       $options
                );
        }
 }