Index: trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt |
— | — | @@ -775,22 +775,25 @@ |
776 | 776 | = "{{" target:template_target params:("|" p:template_param { return p })* "}}" { |
777 | 777 | var obj = { type: 'TAG', name: 'template', attribs: [['target', target]] } |
778 | 778 | if (params && params.length) { |
779 | | - obj.attribs.push(params); |
| 779 | + obj.attribs = obj.attribs.concat(params); |
780 | 780 | } |
781 | 781 | // Should actually use a self-closing tag here, but the Node HTML5 |
782 | 782 | // parser only recognizes known self-closing tags for now, so use an |
783 | 783 | // explicit end tag for now. |
| 784 | + //console.log(pp(obj)); |
784 | 785 | return [obj, {type: 'ENDTAG', name: 'template'}]; |
785 | 786 | } |
786 | 787 | |
787 | 788 | template_target |
788 | 789 | = h:( !"}}" x:([^|\n]) { return x } )* { return h.join(''); } |
789 | 790 | |
| 791 | +/* XXX: pass these as convenient js structures to later stages, but serialize |
| 792 | + * (to json) before passing remaining args to the tree builder */ |
790 | 793 | template_param |
791 | 794 | = name:template_param_name "=" c:template_param_text { |
792 | | - return [name, c]; |
| 795 | + return ['data-k-' + name, c]; |
793 | 796 | } / c:template_param_text { |
794 | | - return [null, c]; |
| 797 | + return ['data-p-', c]; |
795 | 798 | } |
796 | 799 | |
797 | 800 | tplarg |
— | — | @@ -801,7 +804,7 @@ |
802 | 805 | attribs: [['argname', name]] |
803 | 806 | }; |
804 | 807 | if (params && params.length) { |
805 | | - obj.attribs.push(params); |
| 808 | + obj.attribs = obj.attribs.concat(params); |
806 | 809 | } |
807 | 810 | return obj; |
808 | 811 | } |
— | — | @@ -810,9 +813,10 @@ |
811 | 814 | = h:( !"}}" x:([^=|\n]) { return x } )* { return h.join(''); } |
812 | 815 | |
813 | 816 | template_param_text |
814 | | - = template_param_text_chunk* |
815 | | -/* = h:( !"}}" x:([^|]) { return x } )* { return h.join(''); }*/ |
| 817 | + = tcs:template_param_text_chunk* { return JSON.stringify(tcs); } |
| 818 | + //= h:( !"}}" x:([^|]) { return x } )* { return h.join(''); } |
816 | 819 | |
| 820 | + |
817 | 821 | template_param_text_chunk |
818 | 822 | = comment |
819 | 823 | / xmlish_tag |
— | — | @@ -820,7 +824,8 @@ |
821 | 825 | / template |
822 | 826 | / wikilink |
823 | 827 | / quote |
824 | | - / !"}}" x:([^|\n]) { return x } |
| 828 | + / c:[^}|\n]+ {return {type: 'TEXT', value: c.join('')}} |
| 829 | + / !"}}" x:([^|\n]) { return {type: 'TEXT', value: x} } |
825 | 830 | |
826 | 831 | wikilink |
827 | 832 | = "[[" target:link_target text:("|" lt:link_text { return lt })* "]]" suffix:text? { |