r105539 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105538‎ | r105539 | r105540 >
Date:11:40, 8 December 2011
Author:gwicke
Status:deferred
Tags:
Comment:
A bit of comment clean-up and wrapping of tree building into try/catch block
to actually count failures.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt (modified) (history)
  • /trunk/extensions/VisualEditor/tests/parser/parserTests.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js
@@ -384,32 +384,33 @@
385385 failParseTests++;
386386 console.log('PARSE FAIL', err);
387387 } 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+ //});
394394 //var res = es.HtmlSerializer.stringify(tokens,environment);
 395+
395396 //console.log(JSON.stringify(tokens));
396397 //Slightly better token output debugging:
397398 //console.log( util.inspect( tokens, false, null ).yellow);
398399
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);
402404
403 - // Perform post-processing on DOM.
404 - postProcessor.doPostProcess(treeBuilder.parser.document);
 405+ // Perform post-processing on DOM.
 406+ postProcessor.doPostProcess(treeBuilder.parser.document);
405407
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 ) {
411412 printTitle();
412413 failTreeTests++;
413 - console.log('RENDER FAIL', err);
 414+ console.log('RENDER FAIL', e);
414415 return;
415416 }
416417
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js
@@ -1,13 +1,9 @@
22 /**
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)
55 *
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.
128 */
139 function PegTokenizer(env) {
1410 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. */
34 {
45 /* Fixme: use static functions to separate module! Unfortunately, this
56 * does not work:
@@ -1196,4 +1197,4 @@
11971198
11981199
11991200 /* 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 : */

Status & tagging log