r112017 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112016‎ | r112017 | r112018 >
Date:14:44, 21 February 2012
Author:gwicke
Status:deferred
Tags:
Comment:
Add list of HTML5 and deprecated HTML3/4 elements in preparation for
end-of-potential-extension rules; Support indented tag-wrapped pre blocks.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt
@@ -319,7 +319,7 @@
320320
321321 text = t:text_char+ { return t.join(''); }
322322
323 -/* Explanation of chars
 323+/* Legend
324324 * ' quotes (italic/bold)
325325 * < start of xmlish_tag
326326 * ~ signatures/dates
@@ -562,7 +562,6 @@
563563 / pre
564564 / comment &eolf
565565 / nowiki
566 - / pre
567566 / bt:block_tag { return [bt] } // avoid a paragraph if we know that the line starts with a block tag
568567 / para
569568 / inlineline // includes generic tags; wrapped into paragraphs in DOM postprocessor
@@ -637,6 +636,10 @@
638637 //console.warn( 'equal stop @' + pos + input.substr(pos-1, 4) );
639638 return true;
640639 }
 640+ / & { return syntaxFlags['pre']; } '</pre>' {
 641+ //console.warn( 'pre stop @' + pos + input.substr(pos-1, 4) );
 642+ return true;
 643+ }
641644
642645 inline
643646 = c:(urltext / (! inline_breaks (inline_element / . )))+ {
@@ -702,11 +705,31 @@
703706
704707
705708 pre_indent
706 - = l:pre_indent_line ls:(sol pre_indent_line)* {
 709+ = pre_indent_in_tags
 710+ / l:pre_indent_line ls:(sol pre_indent_line)* {
707711 return [new TagTk( 'pre' )]
708712 .concat( [l], ls
709713 , [new EndTagTk( 'pre' )]);
710714 }
 715+
 716+// An indented pre block that is surrounded with pre tags. The pre tags are
 717+// used directly.
 718+pre_indent_in_tags
 719+ = space+ // XXX: capture space for round-tripping
 720+ "<pre"
 721+ attribs:generic_attribute*
 722+ ">"
 723+ & { return setFlag('pre'); }
 724+ l:inlineline
 725+ ls:(sol pre_indent_line)*
 726+ "</pre>"
 727+ {
 728+ clearFlag('pre');
 729+ return [ new TagTk( 'pre', attribs ) ]
 730+ .concat( l, flatten( ls ), [ new EndTagTk( 'pre' ) ] );
 731+ }
 732+ / & { return clearFlag('pre'); }
 733+
711734 pre_indent_line = space l:inlineline {
712735 return [ '\n' ].concat(l);
713736 }
@@ -984,6 +1007,8 @@
9851008 = "<pre"
9861009 attribs:generic_attribute*
9871010 ">"
 1011+ // MediaWiki <pre> is special in that it converts all pre content to plain
 1012+ // text.
9881013 ts:(t1:[^<]+ { return t1.join('') }
9891014 / nowiki
9901015 / !"</pre>" t2:. { return t2 })+
@@ -1047,6 +1072,40 @@
10481073 return [res];
10491074 }
10501075
 1076+// The list of HTML5 tags, mainly used for the identification of non-html
 1077+// tags. These terminate otherwise tag-eating productions (see list below) in
 1078+// order to support potential extension tags:
 1079+// * comment
 1080+// * pre
 1081+// * nowiki
 1082+html5_tagnames
 1083+ = "a" / "abbr" / "address" / "area" / "article"
 1084+ / "aside" / "audio" / "b" / "base" / "bdi" / "bdo" / "blockquote"
 1085+ / "body" / "br" / "button" / "canvas" / "caption" / "cite" / "code"
 1086+ / "col" / "colgroup" / "command" / "data" / "datalist" / "dd" / "del"
 1087+ / "details" / "dfn" / "div" / "dl" / "dt" / "em" / "embed" / "fieldset"
 1088+ / "figcaption" / "figure" / "footer" / "form"
 1089+ / "h1" / "h2" / "h3" / "h4" / "h5" / "h6" / "head" / "header" / "hgroup"
 1090+ / "hr" / "html" / "i" / "iframe" / "img" / "input" / "ins" / "kbd" / "keygen"
 1091+ / "label" / "legend" / "li" / "link" / "map" / "mark" / "menu" / "meta"
 1092+ / "meter" / "nav" / "noscript" / "object" / "ol" / "optgroup" / "option"
 1093+ / "output" / "p" / "param" / "pre" / "progress" / "q" / "rp" / "rt"
 1094+ / "ruby" / "s" / "samp" / "script" / "section" / "select" / "small"
 1095+ / "source" / "span" / "strong" / "style" / "sub" / "summary" / "sup"
 1096+ / "table" / "tbody" / "td" / "textarea" / "tfoot" / "th" / "thead" / "time"
 1097+ / "title" / "tr" / "track" / "u" / "ul" / "var" / "video" / "wbr"
 1098+
 1099+html_oldnames = "center" / "font" / "tt"
 1100+
 1101+// Simple match on non-html endtags, for use in inline_breaks
 1102+nonhtml_endtag
 1103+ = '</'
 1104+ ! ( html5_tagnames / html_oldnames )
 1105+ [^ >]+
 1106+ ( space / newline ) *
 1107+ [^>]*
 1108+ '>'
 1109+
10511110 /* Generic XML-like tags
10521111 *
10531112 * These also cover extensions (including Cite), which will hook into the

Status & tagging log