https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113805
Revision: 113805
Author: gwicke
Date: 2012-03-14 10:58:11 +0000 (Wed, 14 Mar 2012)
Log Message:
-----------
Improve support for {{!}}, and don't produce a pre for indented tables.
Modified Paths:
--------------
trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js
trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt
Modified:
trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js
===================================================================
--- trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js
2012-03-14 10:46:59 UTC (rev 113804)
+++ trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js
2012-03-14 10:58:11 UTC (rev 113805)
@@ -109,23 +109,27 @@
case '=':
return stops.onStack( 'equal' ) ||
( counters.h &&
- input.substr( pos + 1, 200)
- .match(/[ \t]*[\r\n]/) !== null ) || null;
+ input.substr( pos + 1, 200)
+ .match(/[ \t]*[\r\n]/) !== null ) ||
null;
case '|':
return counters.pipe ||
counters.template ||
( counters.table &&
- ( input[pos + 1].match(/[|}]/) !== null ||
- counters.tableCellArg
- )
+ ( input[pos + 1].match(/[|}]/) !== null
||
+ counters.tableCellArg
+ )
) || null;
case '{':
// {{!}} pipe templates..
return (
- counters.pipe ||
- counters.template
- ) && input.substr( pos, 5 ) === '{{!}}'
- || null;
+ counters.pipe ||
+ counters.template ||
+ ( counters.table &&
+ ( input.substr(pos, 10) ===
'{{!}}{{!}}' ||
+ counters.tableCellArg
+ )
+ )
+ ) && input.substr( pos, 5 ) === '{{!}}' ||
null;
case "!":
return counters.table && input[pos + 1] === "!" ||
null;
Modified: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt
===================================================================
--- trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt
2012-03-14 10:46:59 UTC (rev 113804)
+++ trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt
2012-03-14 10:58:11 UTC (rev 113805)
@@ -468,14 +468,15 @@
*/
block_line
= h
- / & [{}|] tl:table_lines { return tl; }
/ lists
- // tag-only lines should not trigger pre
- / st:optionalSpaceToken
- bt:(bts:block_tag stl:optionalSpaceToken { return bts.concat(stl) })+
- &eolf {
- return st.concat(bt);
- }
+ / st:optionalSpaceToken
+ r:( & [{}|] tl:table_lines { return tl; }
+ // tag-only lines should not trigger pre either
+ / bts:(bt:block_tag stl:optionalSpaceToken { return bt.concat(stl) })+
+ &eolf { return bts }
+ ) {
+ return st.concat(r);
+ }
/ pre_indent
/ pre
@@ -743,7 +744,7 @@
tplarg
= "{{{"
name:template_param_text?
- params:( ( space / newline )* pipe ( space / newline )* p:template_param {
return p })*
+ params:( ( space / newline )* '|' ( space / newline )* p:template_param {
return p })*
( space / newline )*
"}}}" {
name = flatten( name );
@@ -756,7 +757,7 @@
template_param
= name:template_param_name
// Insanity: MW accepts |foo | = bar | as a single param..
- (pipe (space / newline)* &'=')?
+ ('|' (space / newline)* &'=')?
val:(
s0:space*
"="
@@ -1104,12 +1105,9 @@
}
-// The list of HTML5 tags, mainly used for the identification of non-html
-// tags. These terminate otherwise tag-eating productions (see list below) in
-// order to support potential extension tags:
-// * comment
-// * pre
-// * nowiki
+// The list of HTML5 tags, mainly used for the identification of *non*-html
+// tags. Non-html tags terminate otherwise tag-eating productions (see list
+// below) in order to support potential extension tags.
html5_tagnames
= "a" / "abbr" / "address" / "area" / "article"
/ "aside" / "audio" / "b" / "base" / "bdi" / "bdo" / "blockquote"
@@ -1363,7 +1361,7 @@
/ table_end_tag
table_start_tag
- = "{|"
+ = "{" pipe
ta:generic_attribute*
space*
te:table_end_tag? // can occur somewhere in the middle of the line too
@@ -1377,7 +1375,7 @@
}
table_caption_tag
- = "|+"
+ = pipe "+"
c:inline* {
return [ new TagTk( 'caption' )]
.concat( c, [ new EndTagTk( 'caption' ) ]);
@@ -1386,11 +1384,11 @@
table_row_tag
= //& { console.warn("table row enter"); return true; }
- "|-"
+ pipe "-"
a:generic_attribute*
space*
// handle tables with missing table cells after a row
- td:( s:sol ![|!] tdt:table_data_tag { return s.concat(tdt); } )?
+ td:( s:sol !( pipe / [!] ) tdt:table_data_tag { return s.concat(tdt); } )?
{
// We rely on our tree builder to close the row as needed. This is
// needed to support building tables from fragment templates with
@@ -1406,7 +1404,7 @@
table_data_tags
= pipe
td:table_data_tag
- tds:( "||" tdt:table_data_tag { return tdt } )* {
+ tds:( pipe pipe tdt:table_data_tag { return tdt } )* {
return td.concat(tds);
}
@@ -1446,7 +1444,7 @@
}
table_end_tag
- = "|}" {
+ = pipe "}" {
var tok = [new EndTagTk( 'table' )];
return tok;
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs