r111494 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111493‎ | r111494 | r111495 >
Date:21:25, 14 February 2012
Author:gwicke
Status:deferred
Tags:
Comment:
Improve support for single-line attributes with preprocessor support. 243
tests passing.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt
@@ -461,6 +461,7 @@
462462 return flatten_string ( r );
463463 }
464464
 465+
465466 wikilink_preprocessor_text
466467 = r:( t:[^%<~[{\n\r\t|!\]} &=]+ { return t.join(''); }
467468 / urlencoded_char
@@ -501,6 +502,27 @@
502503 return flatten_string ( r );
503504 }
504505
 506+// Variants with the entire attribute on a single line
 507+attribute_preprocessor_text_line
 508+ = r:( ts:(!inline_breaks t:[^=<>{\n\r&'"\t ] {return t})+ { return ts.join(''); }
 509+ / directive
 510+ / !inline_breaks !'\n' [&%] )* {
 511+ //console.warn('prep');
 512+ return flatten_string ( r );
 513+ }
 514+attribute_preprocessor_text_single_line
 515+ = r:( t:[^{&']+ { return t.join(''); }
 516+ / directive
 517+ / !inline_breaks !'\n' [{&] )* {
 518+ return flatten_string ( r );
 519+ }
 520+attribute_preprocessor_text_double_line
 521+ = r:( t:[^{&"]+ { return t.join(''); }
 522+ / directive
 523+ / !inline_breaks !'\n' [{&] )* {
 524+ //console.warn( 'double:' + pp(r) );
 525+ return flatten_string ( r );
 526+ }
505527
506528 // A document (start production) is a sequence of toplevelblocks. Tokens are
507529 // emitted in chunks per toplevelblock to avoid buffering the full document.
@@ -946,7 +968,7 @@
947969 // '=' here.
948970 hs:( '=' inline)?
949971 {
950 - console.warn('link_text' + pp(h) + pp(hs));
 972+ //console.warn('link_text' + pp(h) + pp(hs));
951973 clearFlag('linkdesc');
952974 if( hs !== '' ) {
953975 return h.concat(hs);
@@ -1132,12 +1154,15 @@
11331155
11341156 // XXX: attributes can contain templates and template args!!
11351157 att_value
1136 - = t:(!inline_breaks c:[^ \t'"<>='\n] { return c } )+ {
1137 - return t.join('');
1138 - }
1139 - // XXX: is "\"" also valid html? or just Wikitext?
1140 - / "'" t:[^'>]* "'" { return unquote("'", t.join('')); }
1141 - / '"' t:[^">]* '"' { return unquote('"', t.join('')); }
 1158+ = "'" t:attribute_preprocessor_text_single_line "'" { return t; }
 1159+ / '"' t:attribute_preprocessor_text_double_line '"' { return t; }
 1160+ / attribute_preprocessor_text_line
 1161+// = t:(!inline_breaks c:[^ \t'"<>='\n] { return c } )+ {
 1162+// return t.join('');
 1163+// }
 1164+// // XXX: is "\"" also valid html? or just Wikitext?
 1165+// / "'" t:[^'>]* "'" { return unquote("'", t.join('')); }
 1166+// / '"' t:[^">]* '"' { return unquote('"', t.join('')); }
11421167
11431168 /* Lists */
11441169 lists = e:(dtdd / li) es:(sol (dtdd / li))*

Status & tagging log