Index: trunk/extensions/VisualEditor/modules/parser/ext.core.ParserFunctions.js |
— | — | @@ -429,7 +429,7 @@ |
430 | 430 | return [ "MediaWiki" ]; |
431 | 431 | }; |
432 | 432 | ParserFunctions.prototype['pf_anchorencode'] = function ( target, argList, argDict ) { |
433 | | - return [target]; |
| 433 | + return [ target.trim() ]; |
434 | 434 | }; |
435 | 435 | ParserFunctions.prototype['pf_protectionlevel'] = function ( target, argList, argDict ) { |
436 | 436 | return ['']; |
Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt |
— | — | @@ -505,7 +505,7 @@ |
506 | 506 | * in nested inline productions. |
507 | 507 | */ |
508 | 508 | inline_breaks |
509 | | - = & [=|!}:\r\n\]<] |
| 509 | + = & [=|!}{:\r\n\]<] |
510 | 510 | & { // Important hack: disable caching for this production, as the default |
511 | 511 | // cache key does not take into account flag states! |
512 | 512 | cacheKey = ''; |
— | — | @@ -515,7 +515,7 @@ |
516 | 516 | |
517 | 517 | inline |
518 | 518 | = c:(urltext / (! inline_breaks (inline_element / . )))+ { |
519 | | - //console.warn('inline out:' + pp(out)); |
| 519 | + //console.warn('inline out:' + pp(c)); |
520 | 520 | return flatten_stringlist( c ); |
521 | 521 | } |
522 | 522 | |
— | — | @@ -708,12 +708,19 @@ |
709 | 709 | * 6: {{{{{{·}}}}}} → {{{·{{{·}}}·}}} |
710 | 710 | * 7: {{{{{{{·}}}}}}} → {·{{{·{{{·}}}·}}}·} |
711 | 711 | */ |
712 | | -tplarg_or_template = & '{{{{{' template / tplarg / template |
| 712 | +tplarg_or_template |
| 713 | + = |
| 714 | + ! '{{{{{{{' ( |
| 715 | + &'{{{{{{' tplarg |
| 716 | + / & '{{{{{' template |
| 717 | + / tplarg |
| 718 | + / template |
| 719 | + ) |
713 | 720 | |
714 | 721 | template |
715 | 722 | = "{{" (newline / space)* target:template_param_text |
716 | | - params:(( newline / space )* "|" |
717 | | - r:( &"|" { return new KV( '', '') } // empty argument |
| 723 | + params:(( newline / space )* pipe |
| 724 | + r:( &pipe { return new KV( '', '') } // empty argument |
718 | 725 | / ( newline / space )* p:template_param { return p } |
719 | 726 | ) { return r } |
720 | 727 | )* |
— | — | @@ -734,8 +741,8 @@ |
735 | 742 | |
736 | 743 | tplarg |
737 | 744 | = "{{{" |
738 | | - name:template_param_text |
739 | | - params:( ( space / newline )* "|" ( space / newline )* p:template_param { return p })* |
| 745 | + name:template_param_text? |
| 746 | + params:( ( space / newline )* pipe ( space / newline )* p:template_param { return p })* |
740 | 747 | ( space / newline )* |
741 | 748 | "}}}" { |
742 | 749 | name = flatten( name ); |
— | — | @@ -815,7 +822,7 @@ |
816 | 823 | target:wikilink_preprocessor_text |
817 | 824 | lcontent:( |
818 | 825 | & { return posStack.push('lcontent' , pos); } |
819 | | - lcs:( "|" lt:link_text { return new KV( '', lt ); } )+ { |
| 826 | + lcs:( pipe lt:link_text { return new KV( '', lt ); } )+ { |
820 | 827 | return { pos: posStack.pop('lcontent' , pos), content: lcs }; |
821 | 828 | } |
822 | 829 | |
— | — | @@ -920,7 +927,7 @@ |
921 | 928 | / & { return stops.dec( 'pipe' ); } |
922 | 929 | |
923 | 930 | img_option |
924 | | - = "|" space* |
| 931 | + = pipe space* |
925 | 932 | o:( |
926 | 933 | img_attribute |
927 | 934 | / img_format |
— | — | @@ -1441,7 +1448,7 @@ |
1442 | 1449 | |
1443 | 1450 | table_cell_args |
1444 | 1451 | = & { return stops.inc('tableCellArg'); } |
1445 | | - as:generic_attribute* space* "|" !"|" { |
| 1452 | + as:generic_attribute* space* pipe !pipe { |
1446 | 1453 | stops.dec('tableCellArg'); |
1447 | 1454 | return as; |
1448 | 1455 | } |
— | — | @@ -1715,35 +1722,39 @@ |
1716 | 1723 | // Returns either a list of tokens, or a plain string (if nothing is to be |
1717 | 1724 | // processed). |
1718 | 1725 | preprocessor_text |
1719 | | - = r:( t:[^<~[{\n\r\t|!\]} &=]+ { return t.join(''); } |
1720 | | - / directive |
1721 | | - / !inline_breaks text_char )+ { |
| 1726 | + = r:( t:[^<~[{\n\r\t|!\]}{ &=]+ { return t.join(''); } |
| 1727 | + / !inline_breaks ( |
| 1728 | + directive |
| 1729 | + / text_char ) |
| 1730 | + )+ { |
1722 | 1731 | return flatten ( r ); |
1723 | 1732 | } |
1724 | 1733 | |
1725 | 1734 | spaceless_preprocessor_text |
1726 | | - = r:( t:[^'<~[{\n\r|!\]}\t &=]+ { return t.join(''); } |
1727 | | - / directive |
1728 | | - / !inline_breaks !' ' text_char )+ { |
| 1735 | + = r:( t:[^'<~[{\n\r|!\]}{\t &=]+ { return t.join(''); } |
| 1736 | + / !inline_breaks ( |
| 1737 | + directive |
| 1738 | + / !' ' text_char ) |
| 1739 | + )+ { |
1729 | 1740 | return flatten_string ( r ); |
1730 | 1741 | } |
1731 | 1742 | |
1732 | 1743 | |
1733 | 1744 | wikilink_preprocessor_text |
1734 | | - = r:( t:[^<~[{\n\r\t|!\]} &=]+ { return t.join(''); } |
1735 | | - /// urlencoded_char |
1736 | | - / directive |
1737 | | - / !inline_breaks !"|" !"]]" text_char )+ { |
| 1745 | + = r:( t:[^<~[{\n\r\t|!\]}{ &=]+ { return t.join(''); } |
| 1746 | + /// urlencoded_char |
| 1747 | + / !inline_breaks ( directive / !"]]" text_char ) |
| 1748 | + )+ { |
1738 | 1749 | return flatten_stringlist ( r ); |
1739 | 1750 | } |
1740 | 1751 | |
1741 | 1752 | extlink_preprocessor_text |
1742 | 1753 | // added special separator character class inline: separates url from |
1743 | 1754 | // description / text |
1744 | | - = r:( t:[^'<~[{\n\r|!\]}\t&="' \u00A0\u1680\u180E\u2000-\u200A\u202F\u205F\u3000]+ { return t.join(''); } |
1745 | | - / directive |
| 1755 | + = r:( t:[^'<~[{\n\r|!\]}{\t&="' \u00A0\u1680\u180E\u2000-\u200A\u202F\u205F\u3000]+ { return t.join(''); } |
| 1756 | + / !inline_breaks ( directive / no_punctuation_char ) |
1746 | 1757 | /// urlencoded_char |
1747 | | - / !inline_breaks no_punctuation_char |
| 1758 | + // !inline_breaks no_punctuation_char |
1748 | 1759 | / s:[.:,] !(space / eolf) { return s } |
1749 | 1760 | / [&%] )+ { |
1750 | 1761 | return flatten_string ( r ); |
— | — | @@ -1752,21 +1763,32 @@ |
1753 | 1764 | // Attribute values with preprocessor support |
1754 | 1765 | attribute_preprocessor_text |
1755 | 1766 | = r:( ts:(!inline_breaks t:[^=<>{\n\r&'"\t ] {return t})+ { return ts.join(''); } |
1756 | | - / directive |
1757 | | - / !inline_breaks [&%] )+ { |
| 1767 | + / !inline_breaks ( |
| 1768 | + directive |
| 1769 | + / !inline_breaks [&%] |
| 1770 | + ) |
| 1771 | + )+ |
| 1772 | + { |
1758 | 1773 | //console.warn('prep'); |
1759 | 1774 | return flatten_string ( r ); |
1760 | 1775 | } |
| 1776 | + |
1761 | 1777 | attribute_preprocessor_text_single |
1762 | 1778 | = r:( t:[^{&']+ { return t.join(''); } |
1763 | | - / directive |
1764 | | - / !inline_breaks [{&] )* { |
| 1779 | + / !inline_breaks ( |
| 1780 | + directive |
| 1781 | + / [{&] ) |
| 1782 | + )* |
| 1783 | + { |
1765 | 1784 | return flatten_string ( r ); |
1766 | 1785 | } |
1767 | 1786 | attribute_preprocessor_text_double |
1768 | 1787 | = r:( t:[^{&"]+ { return t.join(''); } |
1769 | | - / directive |
1770 | | - / !inline_breaks [{&] )* { |
| 1788 | + / !inline_breaks ( |
| 1789 | + directive |
| 1790 | + / [{&] ) |
| 1791 | + )* |
| 1792 | + { |
1771 | 1793 | //console.warn( 'double:' + pp(r) ); |
1772 | 1794 | return flatten_string ( r ); |
1773 | 1795 | } |
— | — | @@ -1774,21 +1796,28 @@ |
1775 | 1797 | // Variants with the entire attribute on a single line |
1776 | 1798 | attribute_preprocessor_text_line |
1777 | 1799 | = r:( ts:(!inline_breaks t:[^=<>{\n\r&'"\t ] {return t})+ { return ts.join(''); } |
1778 | | - / directive |
1779 | | - / !inline_breaks !'\n' [&%] )+ { |
| 1800 | + / !inline_breaks ( |
| 1801 | + directive |
| 1802 | + / !'\n' [&%] ) |
| 1803 | + )+ { |
1780 | 1804 | //console.warn('prep'); |
1781 | 1805 | return flatten_string ( r ); |
1782 | 1806 | } |
| 1807 | + |
1783 | 1808 | attribute_preprocessor_text_single_line |
1784 | 1809 | = r:( t:[^{&']+ { return t.join(''); } |
1785 | | - / directive |
1786 | | - / !inline_breaks !'\n' [{&] )* { |
| 1810 | + / !inline_breaks ( |
| 1811 | + directive |
| 1812 | + / !'\n' [{&] ) |
| 1813 | + )* { |
1787 | 1814 | return flatten_string ( r ); |
1788 | 1815 | } |
1789 | 1816 | attribute_preprocessor_text_double_line |
1790 | 1817 | = r:( t:[^{&"]+ { return t.join(''); } |
1791 | | - / directive |
1792 | | - / !inline_breaks !'\n' [{&] )* { |
| 1818 | + / !inline_breaks ( |
| 1819 | + directive |
| 1820 | + / !'\n' [{&] ) |
| 1821 | + )* { |
1793 | 1822 | //console.warn( 'double:' + pp(r) ); |
1794 | 1823 | return flatten_string ( r ); |
1795 | 1824 | } |
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js |
— | — | @@ -119,6 +119,12 @@ |
120 | 120 | counters.tableCellArg |
121 | 121 | ) |
122 | 122 | ) || null; |
| 123 | + case '{': |
| 124 | + return ( |
| 125 | + counters.pipe || |
| 126 | + counters.template |
| 127 | + ) && input.substr( pos, 5 ) === '{{!}}' |
| 128 | + || null; |
123 | 129 | case "!": |
124 | 130 | return counters.table && input[pos + 1] === "!" || |
125 | 131 | null; |
Index: trunk/extensions/VisualEditor/modules/parser/ext.core.TemplateHandler.js |
— | — | @@ -168,9 +168,9 @@ |
169 | 169 | var prefix = target.split(':', 1)[0].toLowerCase().trim(); |
170 | 170 | if ( prefix && 'pf_' + prefix in this.parserFunctions ) { |
171 | 171 | var funcArg = target.substr( prefix.length + 1 ); |
172 | | - this.manager.env.tp( 'func prefix: ', prefix, |
173 | | - ' args=', tplExpandData.expandedArgs, |
174 | | - ' funcArg=', funcArg); |
| 172 | + this.manager.env.tp( 'func prefix/args: ', prefix, |
| 173 | + tplExpandData.expandedArgs, |
| 174 | + 'funcArg:', funcArg); |
175 | 175 | //this.manager.env.dp( 'entering prefix', funcArg, args ); |
176 | 176 | res = this.parserFunctions[ 'pf_' + prefix ]( funcArg, |
177 | 177 | tplExpandData.expandedArgs, args, tplExpandData.origToken.attribs ); |
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.parser.environment.js |
— | — | @@ -177,8 +177,12 @@ |
178 | 178 | forceNS = ''; |
179 | 179 | } |
180 | 180 | |
| 181 | + |
181 | 182 | name = name.trim().replace(/[\s_]+/g, '_'); |
182 | 183 | |
| 184 | + // XXX: strip subst for now.. |
| 185 | + name = name.replace( /^subst:/, '' ); |
| 186 | + |
183 | 187 | // Implement int: as alias for MediaWiki: |
184 | 188 | if ( name.substr( 0, 4 ) === 'int:' ) { |
185 | 189 | name = 'MediaWiki:' + name.substr( 4 ); |