Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js |
— | — | @@ -404,7 +404,7 @@ |
405 | 405 | pThingy.tokenDispatcher.transformTokens( res.tokens ); |
406 | 406 | |
407 | 407 | // XXX make this NOT a property |
408 | | - var out = pThingy.out; |
| 408 | + var out = pThingy.document.body.innerHTML; |
409 | 409 | |
410 | 410 | // Finally, check the result vs. the expected result. |
411 | 411 | this.checkResult( this.currentItem, out ); |
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js |
— | — | @@ -6,11 +6,13 @@ |
7 | 7 | * output. |
8 | 8 | */ |
9 | 9 | |
10 | | -var PEG = require('pegjs'); |
| 10 | +var PEG = require('pegjs'), |
| 11 | + path = require('path'), |
| 12 | + fs = require('fs'); |
11 | 13 | |
12 | | -function PegTokenizer(env, src) { |
13 | | - this.env = env || {}; |
14 | | - this.src = src; |
| 14 | +function PegTokenizer() { |
| 15 | + var pegSrcPath = path.join( __dirname, 'pegTokenizer.pegjs.txt' ); |
| 16 | + this.src = fs.readFileSync( pegSrcPath, 'utf8' ); |
15 | 17 | } |
16 | 18 | |
17 | 19 | PegTokenizer.src = false; |
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.parser.js |
— | — | @@ -25,15 +25,9 @@ |
26 | 26 | config = {}; |
27 | 27 | } |
28 | 28 | |
29 | | - if ( !config.peg ) { |
30 | | - // n.b. __dirname is relative to the module. |
31 | | - var pegSrcPath = path.join( __dirname, 'pegTokenizer.pegjs.txt' ); |
32 | | - config.peg = fs.readFileSync( pegSrcPath, 'utf8' ); |
33 | | - } |
34 | 29 | |
| 30 | + this.wikiTokenizer = new PegTokenizer(); |
35 | 31 | |
36 | | - this.wikiTokenizer = new PegTokenizer(config.parserEnv, config.peg); |
37 | | - |
38 | 32 | this.postProcessor = new DOMPostProcessor(); |
39 | 33 | |
40 | 34 | this.DOMConverter = new DOMConverter(); |
— | — | @@ -69,6 +63,9 @@ |
70 | 64 | // event) |
71 | 65 | pthingy.postProcessor.doPostProcess(treeBuilder.document); |
72 | 66 | |
| 67 | + // FIXME: move HTML serialization to separate pipeline! |
| 68 | + pthingy.document = treeBuilder.document; |
| 69 | + |
73 | 70 | // XXX: emit event with result |
74 | 71 | pthingy.getWikiDom = function() { |
75 | 72 | return JSON.stringify( |