Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js |
— | — | @@ -384,32 +384,33 @@ |
385 | 385 | failParseTests++; |
386 | 386 | console.log('PARSE FAIL', err); |
387 | 387 | } else { |
388 | | - var environment = new MWParserEnvironment({ |
389 | | - tagHooks: { |
390 | | - 'ref': MWRefTagHook, |
391 | | - 'references': MWReferencesTagHook |
392 | | - } |
393 | | - }); |
| 388 | + //var environment = new MWParserEnvironment({ |
| 389 | + // tagHooks: { |
| 390 | + // 'ref': MWRefTagHook, |
| 391 | + // 'references': MWReferencesTagHook |
| 392 | + // } |
| 393 | + //}); |
394 | 394 | //var res = es.HtmlSerializer.stringify(tokens,environment); |
| 395 | + |
395 | 396 | //console.log(JSON.stringify(tokens)); |
396 | 397 | //Slightly better token output debugging: |
397 | 398 | //console.log( util.inspect( tokens, false, null ).yellow); |
398 | 399 | |
399 | | - // Build a DOM tree from tokens using the HTML tree |
400 | | - // builder/parser. |
401 | | - processTokens(tokens, treeBuilder); |
| 400 | + try { |
| 401 | + // Build a DOM tree from tokens using the HTML tree |
| 402 | + // builder/parser. |
| 403 | + processTokens(tokens, treeBuilder); |
402 | 404 | |
403 | | - // Perform post-processing on DOM. |
404 | | - postProcessor.doPostProcess(treeBuilder.parser.document); |
| 405 | + // Perform post-processing on DOM. |
| 406 | + postProcessor.doPostProcess(treeBuilder.parser.document); |
405 | 407 | |
406 | | - // And serialize the result. |
407 | | - var out = treeBuilder.body() |
408 | | - .innerHTML; |
409 | | - |
410 | | - if ( err ) { |
| 408 | + // And serialize the result. |
| 409 | + var out = treeBuilder.body() |
| 410 | + .innerHTML; |
| 411 | + } catch ( e ) { |
411 | 412 | printTitle(); |
412 | 413 | failTreeTests++; |
413 | | - console.log('RENDER FAIL', err); |
| 414 | + console.log('RENDER FAIL', e); |
414 | 415 | return; |
415 | 416 | } |
416 | 417 | |
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js |
— | — | @@ -1,13 +1,9 @@ |
2 | 2 | /** |
3 | | - * Parser for wikitext to provisional temp structure, using PEG.js and |
4 | | - * a separate PEG grammar file (pegParser.pegjs.txt) |
| 3 | + * Tokenizer for wikitext, using PEG.js and a separate PEG grammar file |
| 4 | + * (pegTokenizer.pegjs.txt) |
5 | 5 | * |
6 | | - * Use along with the MWTreeRenderer and MWTreeSerializer classes for |
7 | | - * HTML output and source round-tripping. |
8 | | - * |
9 | | - * If installed as a user script or to customize, set parserPlaygroundPegPage |
10 | | - * to point at the MW page name containing the parser peg definition; default |
11 | | - * is 'MediaWiki:Gadget-ParserPlayground-PegParser.pegjs'. |
| 6 | + * Use along with a HTML5TreeBuilder and the DOMPostProcessor(s) for HTML |
| 7 | + * output. |
12 | 8 | */ |
13 | 9 | function PegTokenizer(env) { |
14 | 10 | this.env = env || {}; |
Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt |
— | — | @@ -1,4 +1,5 @@ |
2 | | -/* Produces output more or less compatible with FakeParser; plug it into FP's output and see */ |
| 2 | +/* Combined Wiki (MediaWiki) and HTML tokenizer. Produces a token stream |
| 3 | +** (actually a list of tokens for now) suitable for a HTML5TreeBuilder. */ |
3 | 4 | { |
4 | 5 | /* Fixme: use static functions to separate module! Unfortunately, this |
5 | 6 | * does not work: |
— | — | @@ -1196,4 +1197,4 @@ |
1197 | 1198 | |
1198 | 1199 | |
1199 | 1200 | /* Tabs do not mix well with the hybrid production syntax */ |
1200 | | -/* vim: set filetype=javascript expandtab ts=4 sw=4 cindent: */ |
| 1201 | +/* vim: set filetype=javascript expandtab ts=4 sw=4 cindent : */ |