Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt |
— | — | @@ -319,7 +319,7 @@ |
320 | 320 | |
321 | 321 | text = t:text_char+ { return t.join(''); } |
322 | 322 | |
323 | | -/* Explanation of chars |
| 323 | +/* Legend |
324 | 324 | * ' quotes (italic/bold) |
325 | 325 | * < start of xmlish_tag |
326 | 326 | * ~ signatures/dates |
— | — | @@ -562,7 +562,6 @@ |
563 | 563 | / pre |
564 | 564 | / comment &eolf |
565 | 565 | / nowiki |
566 | | - / pre |
567 | 566 | / bt:block_tag { return [bt] } // avoid a paragraph if we know that the line starts with a block tag |
568 | 567 | / para |
569 | 568 | / inlineline // includes generic tags; wrapped into paragraphs in DOM postprocessor |
— | — | @@ -637,6 +636,10 @@ |
638 | 637 | //console.warn( 'equal stop @' + pos + input.substr(pos-1, 4) ); |
639 | 638 | return true; |
640 | 639 | } |
| 640 | + / & { return syntaxFlags['pre']; } '</pre>' { |
| 641 | + //console.warn( 'pre stop @' + pos + input.substr(pos-1, 4) ); |
| 642 | + return true; |
| 643 | + } |
641 | 644 | |
642 | 645 | inline |
643 | 646 | = c:(urltext / (! inline_breaks (inline_element / . )))+ { |
— | — | @@ -702,11 +705,31 @@ |
703 | 706 | |
704 | 707 | |
705 | 708 | 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)* { |
707 | 711 | return [new TagTk( 'pre' )] |
708 | 712 | .concat( [l], ls |
709 | 713 | , [new EndTagTk( 'pre' )]); |
710 | 714 | } |
| 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 | + |
711 | 734 | pre_indent_line = space l:inlineline { |
712 | 735 | return [ '\n' ].concat(l); |
713 | 736 | } |
— | — | @@ -984,6 +1007,8 @@ |
985 | 1008 | = "<pre" |
986 | 1009 | attribs:generic_attribute* |
987 | 1010 | ">" |
| 1011 | + // MediaWiki <pre> is special in that it converts all pre content to plain |
| 1012 | + // text. |
988 | 1013 | ts:(t1:[^<]+ { return t1.join('') } |
989 | 1014 | / nowiki |
990 | 1015 | / !"</pre>" t2:. { return t2 })+ |
— | — | @@ -1047,6 +1072,40 @@ |
1048 | 1073 | return [res]; |
1049 | 1074 | } |
1050 | 1075 | |
| 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 | + |
1051 | 1110 | /* Generic XML-like tags |
1052 | 1111 | * |
1053 | 1112 | * These also cover extensions (including Cite), which will hook into the |