r113909 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113908‎ | r113909 | r113910 >
Date:11:43, 15 March 2012
Author:gwicke
Status:deferred
Tags:
Comment:
Enable support for block-level wiki constructs in template arguments. This
gets a bit closer to supporting table fragments passed through template
arguments. Next, we'll need a way to indicate start-of-line position to
enable sol block-levels in template parameters.

Example:

{|
{{#if: true|{{!}}Table cell|}}
|}
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt
@@ -432,17 +432,17 @@
433433 * The actual contents of each block.
434434 */
435435 block
436 - = block_lines
 436+ = block_lines
437437 / & '<' r:( pre // tag variant can start anywhere
438438 / comment &eolf
439439 / nowiki
440440 // avoid a paragraph if we know that the line starts with a block tag
441441 / bt:block_tag { return [bt] }
442442 ) { return r; }
443 - / para
 443+ / paragraph
444444 // Inlineline includes generic tags; wrapped into paragraphs in token
445445 // transform and DOM postprocessor
446 - / inlineline
 446+ / inlineline
447447 / sol
448448
449449 /*
@@ -484,9 +484,9 @@
485485 /*
486486 * A paragraph. We don't emit 'p' tokens to avoid issues with template
487487 * transclusions, <p> tags in the source and the like. Instead, we perform
488 - * some paragraph wrapping on the DOM.
 488+ * some paragraph wrapping on the token stream and the DOM.
489489 */
490 -para
 490+paragraph
491491 = s1:sol s2:sol c:inlineline {
492492 return s1.concat(s2, /* [new TagTk('p')],*/ c);
493493 }
@@ -794,7 +794,7 @@
795795 // FIXME: handle template args and templates in key! (or even parser functions?)
796796 template_param_name
797797 = & { return stops.push( 'equal', true ) }
798 - tpt:template_param_text
 798+ tpt:(template_param_text / &'=' { return '' })
799799 {
800800 stops.pop( 'equal' );
801801 //console.warn( 'template param name matched: ' + pp( tpt ) );
@@ -815,8 +815,14 @@
816816 / & { return stops.pop( 'equal' ) }
817817
818818 template_param_text
819 - = & { stops.push('table', false ); return stops.inc('template') }
820 - il:( inline / nested_block )+ {
 819+ = & { /*console.warn( 'tpt: ' +
 820+ input.substr( pos - 10, 9) +
 821+ input[pos].green +
 822+ input.substr( pos +1, 9) ); */
 823+ stops.push('table', false );
 824+ return stops.inc('template')
 825+ }
 826+ il:nested_block+ {
821827 stops.pop('table');
822828 stops.dec('template');
823829 //console.warn( 'tpt match: ' + pp (il));
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js
@@ -12,6 +12,7 @@
1313 fs = require('fs'),
1414 $ = require('jquery'),
1515 events = require('events'),
 16+ //colors = require('colors'),
1617 defines = require('./mediawiki.parser.defines.js');
1718
1819 function PegTokenizer() {

Status & tagging log