Index: trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt |
— | — | @@ -475,12 +475,14 @@ |
476 | 476 | // return res |
477 | 477 | // } |
478 | 478 | |
479 | | -htmlentity = "&" c:[#0-9a-zA-Z]+ ";" { return unentity("&" + c.join('') + ";") } |
| 479 | +htmlentity = "&" c:[#0-9a-zA-Z]+ ";" { |
| 480 | + return unentity("&" + c.join('') + ";") |
| 481 | +} |
480 | 482 | |
481 | 483 | space |
482 | 484 | = s:[ \t]+ { return s.join(''); } |
483 | 485 | |
484 | | -spaceTokenList |
| 486 | +optionalSpaceToken |
485 | 487 | = s:space* { |
486 | 488 | if ( s.length ) { |
487 | 489 | return [{type: 'TEXT', value: s.join('')}]; |
— | — | @@ -551,8 +553,8 @@ |
552 | 554 | / table |
553 | 555 | / lists |
554 | 556 | // tag-only lines should not trigger pre |
555 | | - / st:spaceTokenList |
556 | | - bt:(bts:block_tag stl:spaceTokenList { return bts.concat(stl) })+ |
| 557 | + / st:optionalSpaceToken |
| 558 | + bt:(bts:block_tag stl:optionalSpaceToken { return bts.concat(stl) })+ |
557 | 559 | &eolf { |
558 | 560 | return st.concat(bt); |
559 | 561 | } |
— | — | @@ -774,9 +776,23 @@ |
775 | 777 | |
776 | 778 | template |
777 | 779 | = "{{" target:template_target params:("|" p:template_param { return p })* "}}" { |
778 | | - var obj = { type: 'TAG', name: 'template', attribs: [['target', target]] } |
| 780 | + var obj = { type: 'TAG', name: 'template', |
| 781 | + attribs: [['target', target]], |
| 782 | + args: {}} |
779 | 783 | if (params && params.length) { |
780 | | - obj.attribs = obj.attribs.concat(params); |
| 784 | + var position = 1; |
| 785 | + for ( var i = 0, l = params.length; i < l; i++ ) { |
| 786 | + var param = params[i]; |
| 787 | + if ( param[0] === null ) { |
| 788 | + obj.args[position] = param[1]; |
| 789 | + position++; |
| 790 | + } else { |
| 791 | + obj.args[param[0]] = param[1]; |
| 792 | + } |
| 793 | + } |
| 794 | + // HACK: temporarily also push the args into an attribute |
| 795 | + // (just for debugging) |
| 796 | + obj.attribs.push(['data-args', JSON.stringify(obj.args)]); |
781 | 797 | } |
782 | 798 | // Should actually use a self-closing tag here, but the Node HTML5 |
783 | 799 | // parser only recognizes known self-closing tags for now, so use an |
— | — | @@ -792,20 +808,20 @@ |
793 | 809 | * (to json) before passing remaining args to the tree builder */ |
794 | 810 | template_param |
795 | 811 | = name:template_param_name "=" c:template_param_text { |
796 | | - return ['data-k-' + name, c]; |
| 812 | + return [name, c]; |
797 | 813 | } / c:template_param_text { |
798 | | - return ['data-p-', c]; |
| 814 | + return [null, c]; |
799 | 815 | } |
800 | 816 | |
801 | 817 | tplarg |
802 | | - = "{{{" name:link_target params:("|" p:template_param { return p })* "}}}" { |
| 818 | + = "{{{" name:link_target params:("|" ! "}}}" p:template_param { return p })* "}}}" { |
803 | 819 | var obj = { |
804 | 820 | type: 'SELFCLOSINGTAG', |
805 | 821 | name: 'templatearg', |
806 | 822 | attribs: [['argname', name]] |
807 | 823 | }; |
808 | 824 | if (params && params.length) { |
809 | | - obj.attribs = obj.attribs.concat(params); |
| 825 | + obj.attribs.push(['data-args', JSON.stringify(params)]); |
810 | 826 | } |
811 | 827 | return obj; |
812 | 828 | } |
— | — | @@ -818,6 +834,7 @@ |
819 | 835 | //= h:( !"}}" x:([^|]) { return x } )* { return h.join(''); } |
820 | 836 | |
821 | 837 | |
| 838 | +// XXX: convert to inlineline with syntactic stop on "}}" |
822 | 839 | template_param_text_chunk |
823 | 840 | = comment |
824 | 841 | / xmlish_tag |