Index: trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt |
— | — | @@ -404,6 +404,8 @@ |
405 | 405 | / pre |
406 | 406 | / comment &eolf |
407 | 407 | / para |
| 408 | + / pre |
| 409 | + / block_tag |
408 | 410 | / (s:sol { |
409 | 411 | if (s) { |
410 | 412 | return [s, {type: 'NEWLINE'}]; |
— | — | @@ -424,7 +426,7 @@ |
425 | 427 | / lists |
426 | 428 | / pre_indent |
427 | 429 | / pre |
428 | | - / space* !nowiki generic_tag space* &eolf // XXX: only match block elements! |
| 430 | + / space* block_tag space* &eolf |
429 | 431 | |
430 | 432 | |
431 | 433 | /* Headings */ |
— | — | @@ -743,7 +745,7 @@ |
744 | 746 | return [ {type: 'TAG', name: 'pre', attribs: attribs} ] |
745 | 747 | .concat(ts, [{type: 'ENDTAG', name: 'pre'}]); |
746 | 748 | } |
747 | | - / "</pre>" { return {type: 'TEXT', value: "</pre>"}; } |
| 749 | + /// "</pre>" { return {type: 'TEXT', value: "</pre>"}; } |
748 | 750 | |
749 | 751 | nowiki |
750 | 752 | = "<nowiki>" nc:nowiki_content "</nowiki>" { return nc } |
— | — | @@ -766,6 +768,30 @@ |
767 | 769 | |
768 | 770 | // See http://dev.w3.org/html5/spec/Overview.html#syntax-tag-name and |
769 | 771 | // 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 |
770 | 796 | generic_tag |
771 | 797 | = "<" end:"/"? name:[0-9a-zA-Z]+ |
772 | 798 | attribs:generic_attribute* |