r107505 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107504‎ | r107505 | r107506 >
Date:17:04, 28 December 2011
Author:gwicke
Status:deferred
Tags:
Comment:
Remove env and load grammar in tokenizer constructor. Re-add property hack to
keep parserTests running for now. Really need a different pipeline for html
serialization or a reference to the HTML DOM.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/mediawiki.parser.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js (modified) (history)
  • /trunk/extensions/VisualEditor/tests/parser/parserTests.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js
@@ -404,7 +404,7 @@
405405 pThingy.tokenDispatcher.transformTokens( res.tokens );
406406
407407 // XXX make this NOT a property
408 - var out = pThingy.out;
 408+ var out = pThingy.document.body.innerHTML;
409409
410410 // Finally, check the result vs. the expected result.
411411 this.checkResult( this.currentItem, out );
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js
@@ -6,11 +6,13 @@
77 * output.
88 */
99
10 -var PEG = require('pegjs');
 10+var PEG = require('pegjs'),
 11+ path = require('path'),
 12+ fs = require('fs');
1113
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' );
1517 }
1618
1719 PegTokenizer.src = false;
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.parser.js
@@ -25,15 +25,9 @@
2626 config = {};
2727 }
2828
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 - }
3429
 30+ this.wikiTokenizer = new PegTokenizer();
3531
36 - this.wikiTokenizer = new PegTokenizer(config.parserEnv, config.peg);
37 -
3832 this.postProcessor = new DOMPostProcessor();
3933
4034 this.DOMConverter = new DOMConverter();
@@ -69,6 +63,9 @@
7064 // event)
7165 pthingy.postProcessor.doPostProcess(treeBuilder.document);
7266
 67+ // FIXME: move HTML serialization to separate pipeline!
 68+ pthingy.document = treeBuilder.document;
 69+
7370 // XXX: emit event with result
7471 pthingy.getWikiDom = function() {
7572 return JSON.stringify(

Status & tagging log