Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt |
— | — | @@ -669,8 +669,12 @@ |
670 | 670 | tplarg_or_template = & '{{{{{' template / tplarg / template |
671 | 671 | |
672 | 672 | template |
673 | | - = "{{" target:template_param_text |
674 | | - params:(newline? "|" newline? p:template_param { return p })* |
| 673 | + = "{{" (newline / space)* target:template_param_text |
| 674 | + params:(( newline / space )* "|" |
| 675 | + r:( &"|" { return new KV( '', '') } // empty argument |
| 676 | + / newline? p:template_param { return p } |
| 677 | + ) { return r } |
| 678 | + )* |
675 | 679 | "}}" { |
676 | 680 | // Insert target as first positional attribute, so that it can be |
677 | 681 | // generically expanded. The TemplateHandler then needs to shift it out |
— | — | @@ -720,15 +724,15 @@ |
721 | 725 | |
722 | 726 | // FIXME: handle template args and templates in key! (or even parser functions?) |
723 | 727 | template_param_name |
724 | | - = & { return setFlag( 'equal' ) } |
| 728 | + = & { return setFlag( 'equalTemplate' ) } |
725 | 729 | tpt:template_param_text |
726 | 730 | { |
727 | | - clearFlag( 'equal' ); |
| 731 | + clearFlag( 'equalTemplate' ); |
728 | 732 | //console.warn( 'template param name matched: ' + pp( tpt ) ); |
729 | 733 | return tpt; |
730 | 734 | } |
731 | 735 | |
732 | | - / & { return clearFlag( 'equal' ) } |
| 736 | + / & { return clearFlag( 'equalTemplate' ) } |
733 | 737 | //= h:( !"}}" x:([^=|\n]) { return x } )* { return h.join(''); } |
734 | 738 | |
735 | 739 | template_param_text |
— | — | @@ -740,6 +744,7 @@ |
741 | 745 | } |
742 | 746 | / & { return clearFlag('template'); } |
743 | 747 | |
| 748 | + |
744 | 749 | // TODO: handle link prefixes as in al[[Razi]] |
745 | 750 | wikilink |
746 | 751 | = & { return posStack.push('wikilink' , pos); } |
— | — | @@ -1101,6 +1106,7 @@ |
1102 | 1107 | value:(( space / newline )* |
1103 | 1108 | v:generic_attribute_newline_value { return v })? |
1104 | 1109 | { |
| 1110 | + //console.warn('generic_newline_attribute: ' + pp( name )) |
1105 | 1111 | if ( value !== '' ) { |
1106 | 1112 | return new KV( name, value ); |
1107 | 1113 | } else { |
— | — | @@ -1134,15 +1140,15 @@ |
1135 | 1141 | // } |
1136 | 1142 | |
1137 | 1143 | generic_attribute_name |
1138 | | - = & { return setFlag( 'equal' ) } |
| 1144 | + = & { return setFlag( 'equalAttrib' ) } |
1139 | 1145 | ! '/>' |
1140 | 1146 | name:attribute_preprocessor_text_line |
1141 | 1147 | { |
1142 | | - clearFlag( 'equal' ); |
| 1148 | + clearFlag( 'equalAttrib' ); |
1143 | 1149 | //console.warn( 'generic attribute name: ' + pp( name ) ); |
1144 | 1150 | return name; |
1145 | 1151 | } |
1146 | | - / & { return clearFlag( 'equal' ) } |
| 1152 | + / & { return clearFlag( 'equalAttrib' ) } |
1147 | 1153 | |
1148 | 1154 | // A generic attribute, possibly spanning multiple lines. |
1149 | 1155 | generic_attribute_newline_value |
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js |
— | — | @@ -106,7 +106,10 @@ |
107 | 107 | PegTokenizer.prototype.inline_breaks = function (input, pos, syntaxFlags ) { |
108 | 108 | switch( input[pos] ) { |
109 | 109 | case '=': |
110 | | - return syntaxFlags.equal || |
| 110 | + return ( syntaxFlags.equalAttrib && |
| 111 | + (syntaxFlags.equalTemplate || ! syntaxFlags.template ) ) || |
| 112 | + (syntaxFlags.equalTemplate && |
| 113 | + (syntaxFlags.equalAttrib || syntaxFlags.template)) || |
111 | 114 | ( syntaxFlags.h && |
112 | 115 | input.substr( pos + 1, 200) |
113 | 116 | .match(/[ \t]*[\r\n]/) !== null ) || null; |
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.parser.environment.js |
— | — | @@ -244,7 +244,7 @@ |
245 | 245 | this.dp ( 'MWParserEnvironment.tokensToString, non-text token: ' + |
246 | 246 | tstring + JSON.stringify( tokens, null, 2 ) ); |
247 | 247 | //console.trace(); |
248 | | - out.push( tstring ); |
| 248 | + //out.push( tstring ); |
249 | 249 | } |
250 | 250 | } |
251 | 251 | //console.warn( 'MWParserEnvironment.tokensToString result: ' + out.join('') ); |