Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt |
— | — | @@ -662,21 +662,25 @@ |
663 | 663 | |
664 | 664 | //[^][<>"\\x00-\\x20\\x7F\p{Zs}] |
665 | 665 | |
666 | | -no_punctuation_char = [^ :\]\[\n"'<>\x00-\x20\x7f,.&%\u00A0\u1680\u180E\u2000-\u200A\u202F\u205F\u3000] |
| 666 | +// no punctiation, and '{<' to trigger directives |
| 667 | +no_punctuation_char = [^ :\]\[\n"'<>\x00-\x20\x7f,.&%\u00A0\u1680\u180E\u2000-\u200A\u202F\u205F\u3000{] |
667 | 668 | |
668 | 669 | url |
669 | 670 | = proto:url_protocol |
670 | 671 | addr:( ipv6_address / ipv4_address )? |
671 | | - rest:( ( !inline_breaks |
| 672 | + path:( ( !inline_breaks |
672 | 673 | c:no_punctuation_char |
673 | 674 | { return c } |
674 | 675 | ) |
675 | 676 | / s:[.:,] !(space / eolf) { return s } |
| 677 | + / comment |
| 678 | + / tplarg_or_template |
676 | 679 | / htmlentity |
677 | | - /// urlencoded_char |
678 | | - / [&%] )+ |
| 680 | + / [&%{] |
| 681 | + )+ |
679 | 682 | { |
680 | | - return proto + addr + rest.join(''); |
| 683 | + //console.warn( "path: " + pp( flatten_stringlist( [proto + addr].concat( path ) ) ) ); |
| 684 | + return flatten_string( [proto + addr].concat( path ) ); |
681 | 685 | } |
682 | 686 | |
683 | 687 | ipv4_address |
— | — | @@ -710,9 +714,10 @@ |
711 | 715 | = "{{" (newline / space)* target:template_param_text |
712 | 716 | params:(( newline / space )* "|" |
713 | 717 | r:( &"|" { return new KV( '', '') } // empty argument |
714 | | - / newline? p:template_param { return p } |
| 718 | + / ( newline / space )* p:template_param { return p } |
715 | 719 | ) { return r } |
716 | 720 | )* |
| 721 | + ( newline / space )* |
717 | 722 | "}}" { |
718 | 723 | // Insert target as first positional attribute, so that it can be |
719 | 724 | // generically expanded. The TemplateHandler then needs to shift it out |
— | — | @@ -730,7 +735,8 @@ |
731 | 736 | tplarg |
732 | 737 | = "{{{" |
733 | 738 | name:template_param_text |
734 | | - params:( newline? "|" newline? p:template_param { return p })* |
| 739 | + params:( ( space / newline )* "|" ( space / newline )* p:template_param { return p })* |
| 740 | + ( space / newline )* |
735 | 741 | "}}}" { |
736 | 742 | name = flatten( name ); |
737 | 743 | params.unshift( { k: '', v: name } ); |
— | — | @@ -741,17 +747,23 @@ |
742 | 748 | |
743 | 749 | template_param |
744 | 750 | = name:template_param_name |
745 | | - s0:space* |
746 | | - eq:"="? |
747 | | - s1:space* |
748 | | - value:template_param_value? |
| 751 | + val:( |
| 752 | + s0:space* |
| 753 | + "=" |
| 754 | + s1:space* |
| 755 | + value:template_param_value? { |
| 756 | + return { s0: s0, s1: s1, value: value }; |
| 757 | + } |
| 758 | + )? |
749 | 759 | |
750 | 760 | { |
751 | 761 | //console.warn( 'named template_param matched' + pp([name, value ]) ); |
752 | | - if ( value !== '' ) { |
753 | | - return new KV( name, flatten( value ) ); |
754 | | - } else if ( eq !== '' ) { |
755 | | - return new KV(flatten( name ), []); |
| 762 | + if ( val !== '' ) { |
| 763 | + if ( val.value !== '' ) { |
| 764 | + return new KV( name, flatten( val.value ) ); |
| 765 | + } else { |
| 766 | + return new KV(flatten( name ), []); |
| 767 | + } |
756 | 768 | } else { |
757 | 769 | return new KV([], flatten(name)); |
758 | 770 | } |