mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-01 17:36:35 +00:00
5ec30252f1
expansion better.
35 lines
803 B
JavaScript
35 lines
803 B
JavaScript
/**
|
|
* Command line wikidom parse utility.
|
|
* Read from STDIN, write to STDOUT.
|
|
*/
|
|
|
|
|
|
( function() {
|
|
|
|
var ParserPipeline = require('./mediawiki.parser.js').ParserPipeline,
|
|
ParserEnv = require('./mediawiki.parser.environment.js').MWParserEnvironment,
|
|
optimist = require('optimist');
|
|
|
|
var parser = new ParserPipeline( new ParserEnv({}) );
|
|
|
|
|
|
process.stdin.resume();
|
|
process.stdin.setEncoding('utf8');
|
|
|
|
var inputChunks = [];
|
|
process.stdin.on( 'data', function( chunk ) {
|
|
inputChunks.push( chunk );
|
|
} );
|
|
|
|
process.stdin.on( 'end', function() {
|
|
var input = inputChunks.join('');
|
|
parser.parse( input );
|
|
var output = parser.getWikiDom();
|
|
process.stdout.write( output );
|
|
// add a trailing newline for shell user's benefit
|
|
process.stdout.write( "\n" );
|
|
process.exit(0);
|
|
} );
|
|
|
|
} )();
|