r113805 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113804‎ | r113805 | r113806 >
Date:10:58, 14 March 2012
Author:gwicke
Status:deferred
Tags:
Comment:
Improve support for {{!}}, and don't produce a pre for indented tables.
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
@@ -468,14 +468,15 @@
469469 */
470470 block_line
471471 = h
472 - / & [{}|] tl:table_lines { return tl; }
473472 / lists
474 - // tag-only lines should not trigger pre
475 - / st:optionalSpaceToken
476 - bt:(bts:block_tag stl:optionalSpaceToken { return bts.concat(stl) })+
477 - &eolf {
478 - return st.concat(bt);
479 - }
 473+ / st:optionalSpaceToken
 474+ r:( & [{}|] tl:table_lines { return tl; }
 475+ // tag-only lines should not trigger pre either
 476+ / bts:(bt:block_tag stl:optionalSpaceToken { return bt.concat(stl) })+
 477+ &eolf { return bts }
 478+ ) {
 479+ return st.concat(r);
 480+ }
480481 / pre_indent
481482 / pre
482483
@@ -743,7 +744,7 @@
744745 tplarg
745746 = "{{{"
746747 name:template_param_text?
747 - params:( ( space / newline )* pipe ( space / newline )* p:template_param { return p })*
 748+ params:( ( space / newline )* '|' ( space / newline )* p:template_param { return p })*
748749 ( space / newline )*
749750 "}}}" {
750751 name = flatten( name );
@@ -756,7 +757,7 @@
757758 template_param
758759 = name:template_param_name
759760 // Insanity: MW accepts |foo | = bar | as a single param..
760 - (pipe (space / newline)* &'=')?
 761+ ('|' (space / newline)* &'=')?
761762 val:(
762763 s0:space*
763764 "="
@@ -1104,12 +1105,9 @@
11051106 }
11061107
11071108
1108 -// The list of HTML5 tags, mainly used for the identification of non-html
1109 -// tags. These terminate otherwise tag-eating productions (see list below) in
1110 -// order to support potential extension tags:
1111 -// * comment
1112 -// * pre
1113 -// * nowiki
 1109+// The list of HTML5 tags, mainly used for the identification of *non*-html
 1110+// tags. Non-html tags terminate otherwise tag-eating productions (see list
 1111+// below) in order to support potential extension tags.
11141112 html5_tagnames
11151113 = "a" / "abbr" / "address" / "area" / "article"
11161114 / "aside" / "audio" / "b" / "base" / "bdi" / "bdo" / "blockquote"
@@ -1363,7 +1361,7 @@
13641362 / table_end_tag
13651363
13661364 table_start_tag
1367 - = "{|"
 1365+ = "{" pipe
13681366 ta:generic_attribute*
13691367 space*
13701368 te:table_end_tag? // can occur somewhere in the middle of the line too
@@ -1377,7 +1375,7 @@
13781376 }
13791377
13801378 table_caption_tag
1381 - = "|+"
 1379+ = pipe "+"
13821380 c:inline* {
13831381 return [ new TagTk( 'caption' )]
13841382 .concat( c, [ new EndTagTk( 'caption' ) ]);
@@ -1386,11 +1384,11 @@
13871385
13881386 table_row_tag
13891387 = //& { console.warn("table row enter"); return true; }
1390 - "|-"
 1388+ pipe "-"
13911389 a:generic_attribute*
13921390 space*
13931391 // handle tables with missing table cells after a row
1394 - td:( s:sol ![|!] tdt:table_data_tag { return s.concat(tdt); } )?
 1392+ td:( s:sol !( pipe / [!] ) tdt:table_data_tag { return s.concat(tdt); } )?
13951393 {
13961394 // We rely on our tree builder to close the row as needed. This is
13971395 // needed to support building tables from fragment templates with
@@ -1406,7 +1404,7 @@
14071405 table_data_tags
14081406 = pipe
14091407 td:table_data_tag
1410 - tds:( "||" tdt:table_data_tag { return tdt } )* {
 1408+ tds:( pipe pipe tdt:table_data_tag { return tdt } )* {
14111409 return td.concat(tds);
14121410 }
14131411
@@ -1446,7 +1444,7 @@
14471445 }
14481446
14491447 table_end_tag
1450 - = "|}" {
 1448+ = pipe "}" {
14511449 var tok = [new EndTagTk( 'table' )];
14521450 return tok;
14531451 }
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js
@@ -109,23 +109,27 @@
110110 case '=':
111111 return stops.onStack( 'equal' ) ||
112112 ( counters.h &&
113 - input.substr( pos + 1, 200)
114 - .match(/[ \t]*[\r\n]/) !== null ) || null;
 113+ input.substr( pos + 1, 200)
 114+ .match(/[ \t]*[\r\n]/) !== null ) || null;
115115 case '|':
116116 return counters.pipe ||
117117 counters.template ||
118118 ( counters.table &&
119 - ( input[pos + 1].match(/[|}]/) !== null ||
120 - counters.tableCellArg
121 - )
 119+ ( input[pos + 1].match(/[|}]/) !== null ||
 120+ counters.tableCellArg
 121+ )
122122 ) || null;
123123 case '{':
124124 // {{!}} pipe templates..
125125 return (
126 - counters.pipe ||
127 - counters.template
128 - ) && input.substr( pos, 5 ) === '{{!}}'
129 - || null;
 126+ counters.pipe ||
 127+ counters.template ||
 128+ ( counters.table &&
 129+ ( input.substr(pos, 10) === '{{!}}{{!}}' ||
 130+ counters.tableCellArg
 131+ )
 132+ )
 133+ ) && input.substr( pos, 5 ) === '{{!}}' || null;
130134 case "!":
131135 return counters.table && input[pos + 1] === "!" ||
132136 null;

Status & tagging log