r104249 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104248‎ | r104249 | r104250 >
Date:17:41, 25 November 2011
Author:gwicke
Status:deferred
Tags:
Comment:
Separate block-level tags in tokenizer to delimit inlines and avoid wrapping
block-level in paragraphs.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt
@@ -404,6 +404,8 @@
405405 / pre
406406 / comment &eolf
407407 / para
 408+ / pre
 409+ / block_tag
408410 / (s:sol {
409411 if (s) {
410412 return [s, {type: 'NEWLINE'}];
@@ -424,7 +426,7 @@
425427 / lists
426428 / pre_indent
427429 / pre
428 - / space* !nowiki generic_tag space* &eolf // XXX: only match block elements!
 430+ / space* block_tag space* &eolf
429431
430432
431433 /* Headings */
@@ -743,7 +745,7 @@
744746 return [ {type: 'TAG', name: 'pre', attribs: attribs} ]
745747 .concat(ts, [{type: 'ENDTAG', name: 'pre'}]);
746748 }
747 - / "</pre>" { return {type: 'TEXT', value: "</pre>"}; }
 749+ /// "</pre>" { return {type: 'TEXT', value: "</pre>"}; }
748750
749751 nowiki
750752 = "<nowiki>" nc:nowiki_content "</nowiki>" { return nc }
@@ -766,6 +768,30 @@
767769
768770 // See http://dev.w3.org/html5/spec/Overview.html#syntax-tag-name and
769771 // following paragraphs
 772+block_tag
 773+ = "<" end:"/"? name:block_name
 774+ attribs:generic_attribute*
 775+ selfclose:"/"?
 776+ ">" {
 777+ var res = {name: name, attribs: attribs};
 778+ if ( end != '' ) {
 779+ res.type = 'ENDTAG';
 780+ } else if ( selfclose != '' ) {
 781+ res.type = 'SELFCLOSINGTAG';
 782+ } else {
 783+ res.type = 'TAG';
 784+ }
 785+ return res;
 786+ }
 787+
 788+block_name
 789+ = "p" / "table" / "td" / "tr" / "ul" / "ol"
 790+ / "li" / "dt" / "dd" / "div" / "center"
 791+ / "blockquote"
 792+
 793+
 794+// See http://dev.w3.org/html5/spec/Overview.html#syntax-tag-name and
 795+// following paragraphs
770796 generic_tag
771797 = "<" end:"/"? name:[0-9a-zA-Z]+
772798 attribs:generic_attribute*

Status & tagging log