Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt |
— | — | @@ -468,14 +468,15 @@ |
469 | 469 | */ |
470 | 470 | block_line |
471 | 471 | = h |
472 | | - / & [{}|] tl:table_lines { return tl; } |
473 | 472 | / 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 | + } |
480 | 481 | / pre_indent |
481 | 482 | / pre |
482 | 483 | |
— | — | @@ -743,7 +744,7 @@ |
744 | 745 | tplarg |
745 | 746 | = "{{{" |
746 | 747 | 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 })* |
748 | 749 | ( space / newline )* |
749 | 750 | "}}}" { |
750 | 751 | name = flatten( name ); |
— | — | @@ -756,7 +757,7 @@ |
757 | 758 | template_param |
758 | 759 | = name:template_param_name |
759 | 760 | // Insanity: MW accepts |foo | = bar | as a single param.. |
760 | | - (pipe (space / newline)* &'=')? |
| 761 | + ('|' (space / newline)* &'=')? |
761 | 762 | val:( |
762 | 763 | s0:space* |
763 | 764 | "=" |
— | — | @@ -1104,12 +1105,9 @@ |
1105 | 1106 | } |
1106 | 1107 | |
1107 | 1108 | |
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. |
1114 | 1112 | html5_tagnames |
1115 | 1113 | = "a" / "abbr" / "address" / "area" / "article" |
1116 | 1114 | / "aside" / "audio" / "b" / "base" / "bdi" / "bdo" / "blockquote" |
— | — | @@ -1363,7 +1361,7 @@ |
1364 | 1362 | / table_end_tag |
1365 | 1363 | |
1366 | 1364 | table_start_tag |
1367 | | - = "{|" |
| 1365 | + = "{" pipe |
1368 | 1366 | ta:generic_attribute* |
1369 | 1367 | space* |
1370 | 1368 | te:table_end_tag? // can occur somewhere in the middle of the line too |
— | — | @@ -1377,7 +1375,7 @@ |
1378 | 1376 | } |
1379 | 1377 | |
1380 | 1378 | table_caption_tag |
1381 | | - = "|+" |
| 1379 | + = pipe "+" |
1382 | 1380 | c:inline* { |
1383 | 1381 | return [ new TagTk( 'caption' )] |
1384 | 1382 | .concat( c, [ new EndTagTk( 'caption' ) ]); |
— | — | @@ -1386,11 +1384,11 @@ |
1387 | 1385 | |
1388 | 1386 | table_row_tag |
1389 | 1387 | = //& { console.warn("table row enter"); return true; } |
1390 | | - "|-" |
| 1388 | + pipe "-" |
1391 | 1389 | a:generic_attribute* |
1392 | 1390 | space* |
1393 | 1391 | // 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); } )? |
1395 | 1393 | { |
1396 | 1394 | // We rely on our tree builder to close the row as needed. This is |
1397 | 1395 | // needed to support building tables from fragment templates with |
— | — | @@ -1406,7 +1404,7 @@ |
1407 | 1405 | table_data_tags |
1408 | 1406 | = pipe |
1409 | 1407 | td:table_data_tag |
1410 | | - tds:( "||" tdt:table_data_tag { return tdt } )* { |
| 1408 | + tds:( pipe pipe tdt:table_data_tag { return tdt } )* { |
1411 | 1409 | return td.concat(tds); |
1412 | 1410 | } |
1413 | 1411 | |
— | — | @@ -1446,7 +1444,7 @@ |
1447 | 1445 | } |
1448 | 1446 | |
1449 | 1447 | table_end_tag |
1450 | | - = "|}" { |
| 1448 | + = pipe "}" { |
1451 | 1449 | var tok = [new EndTagTk( 'table' )]; |
1452 | 1450 | return tok; |
1453 | 1451 | } |
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js |
— | — | @@ -109,23 +109,27 @@ |
110 | 110 | case '=': |
111 | 111 | return stops.onStack( 'equal' ) || |
112 | 112 | ( 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; |
115 | 115 | case '|': |
116 | 116 | return counters.pipe || |
117 | 117 | counters.template || |
118 | 118 | ( counters.table && |
119 | | - ( input[pos + 1].match(/[|}]/) !== null || |
120 | | - counters.tableCellArg |
121 | | - ) |
| 119 | + ( input[pos + 1].match(/[|}]/) !== null || |
| 120 | + counters.tableCellArg |
| 121 | + ) |
122 | 122 | ) || null; |
123 | 123 | case '{': |
124 | 124 | // {{!}} pipe templates.. |
125 | 125 | 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; |
130 | 134 | case "!": |
131 | 135 | return counters.table && input[pos + 1] === "!" || |
132 | 136 | null; |