60require_once __DIR__ .
'/Maintenance.php';
73 parent::__construct();
77 'Title name for the given wikitext (Default: \'CLIParser\')',
81 $this->
addArg(
'file',
'File containing wikitext (Default: stdin)',
false );
82 $this->
addOption(
'parsoid',
'Whether to use Parsoid',
false,
false,
'p' );
94 public function render( $wikitext ) {
95 $options = ParserOptions::newFromAnon();
96 $options->setOption(
'enableLimitReport',
false );
97 $po = $this->parser->parse(
104 return $pipeline->run( $po, $options, [
'wrapperDivClass' =>
'' ] )->getContentHolderText();
112 $php_stdin =
'php://stdin';
113 $input_file = $this->
getArg( 0, $php_stdin );
115 if ( $input_file === $php_stdin && !$this->mQuiet ) {
117 $this->
error( basename( __FILE__ )
118 .
": warning: reading wikitext from STDIN. Press $ctrl to parse.\n" );
121 return file_get_contents( $input_file );
127 $this->parser = $services->getParsoidParserFactory()->create();
129 $this->parser = $services->getParserFactory()->create();
141 $title = $this->
getOption(
'title' ) ?:
'CLIParser';
143 return Title::newFromText( $title );
149require_once RUN_MAINTENANCE_IF_MAIN;
wfIsWindows()
Check if the operating system is Windows.
Maintenance script to parse some wikitext.
execute()
Do the actual work.
getTitle()
Title object to use for CLI parsing.
__construct()
Default constructor.
Wikitext()
Get wikitext from a the file passed as argument or STDIN.
Parser ParsoidParser $parser
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true, $multi=false)
Add some args that are needed.
getArg( $argId=0, $default=null)
Get an argument.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
hasOption( $name)
Checks to see if a particular option was set.
getOption( $name, $default=null)
Get an option, or return the default.
error( $err, $die=0)
Throw an error to the user.
getServiceContainer()
Returns the main service container.
addDescription( $text)
Set the description text.