Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.parser.defines.js |
— | — | @@ -3,37 +3,40 @@ |
4 | 4 | * strings or String objects (if attributes are needed). |
5 | 5 | */ |
6 | 6 | |
7 | | -var toString = function() { return JSON.stringify( this ); } |
| 7 | +var toString = function() { return JSON.stringify( this ); }; |
8 | 8 | |
9 | | -function TagTk( name, attribs ) { |
| 9 | +function TagTk( name, attribs, dataAttribs ) { |
10 | 10 | //this.type = 'TAG'; |
11 | 11 | this.name = name; |
12 | 12 | this.attribs = attribs || []; |
| 13 | + this.dataAttribs = dataAttribs || {}; |
13 | 14 | } |
14 | | -TagTk.prototype = new Object(); |
| 15 | +TagTk.prototype = {}; |
15 | 16 | TagTk.prototype.toJSON = function () { |
16 | 17 | return $.extend( { type: 'TagTk' }, this ); |
17 | 18 | }; |
18 | 19 | TagTk.prototype.constructor = TagTk; |
19 | 20 | TagTk.prototype.toString = toString; |
20 | 21 | |
21 | | -function EndTagTk( name, attribs ) { |
| 22 | +function EndTagTk( name, attribs, dataAttribs ) { |
22 | 23 | this.name = name; |
23 | 24 | this.attribs = attribs || []; |
| 25 | + this.dataAttribs = dataAttribs || {}; |
24 | 26 | } |
25 | | -EndTagTk.prototype = new Object(); |
| 27 | +EndTagTk.prototype = {}; |
26 | 28 | EndTagTk.prototype.toJSON = function () { |
27 | 29 | return $.extend( { type: 'EndTagTk' }, this ); |
28 | 30 | }; |
29 | 31 | EndTagTk.prototype.constructor = EndTagTk; |
30 | 32 | EndTagTk.prototype.toString = toString; |
31 | 33 | |
32 | | -function SelfclosingTagTk( name, attribs ) { |
| 34 | +function SelfclosingTagTk( name, attribs, dataAttribs ) { |
33 | 35 | //this.type = 'SELFCLOSINGTAG'; |
34 | 36 | this.name = name; |
35 | 37 | this.attribs = attribs || []; |
| 38 | + this.dataAttribs = dataAttribs || {}; |
36 | 39 | } |
37 | | -SelfclosingTagTk.prototype = new Object(); |
| 40 | +SelfclosingTagTk.prototype = {}; |
38 | 41 | SelfclosingTagTk.prototype.toJSON = function () { |
39 | 42 | return $.extend( { type: 'SelfclosingTagTk' }, this ); |
40 | 43 | }; |
— | — | @@ -43,7 +46,7 @@ |
44 | 47 | function NlTk( ) { |
45 | 48 | //this.type = 'NEWLINE'; |
46 | 49 | } |
47 | | -NlTk.prototype = new Object(); |
| 50 | +NlTk.prototype = {}; |
48 | 51 | NlTk.prototype.toJSON = function () { |
49 | 52 | return $.extend( { type: 'NlTk' }, this ); |
50 | 53 | }; |
— | — | @@ -53,7 +56,7 @@ |
54 | 57 | function CommentTk( value ) { |
55 | 58 | this.value = value; |
56 | 59 | } |
57 | | -CommentTk.prototype = new Object(); |
| 60 | +CommentTk.prototype = {}; |
58 | 61 | CommentTk.prototype.toJSON = function () { |
59 | 62 | return $.extend( { type: 'COMMENT' }, this ); |
60 | 63 | }; |
— | — | @@ -61,7 +64,7 @@ |
62 | 65 | CommentTk.prototype.toString = toString; |
63 | 66 | |
64 | 67 | function EOFTk( ) { } |
65 | | -EOFTk.prototype = new Object(); |
| 68 | +EOFTk.prototype = {}; |
66 | 69 | EOFTk.prototype.toJSON = function () { |
67 | 70 | return $.extend( { type: 'EOFTk' }, this ); |
68 | 71 | }; |
Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt |
— | — | @@ -754,6 +754,8 @@ |
755 | 755 | |
756 | 756 | template_param |
757 | 757 | = name:template_param_name |
| 758 | + // Insanity: MW accepts |foo | = bar as a single param.. |
| 759 | + (pipe (space / newline)* &'=')? |
758 | 760 | val:( |
759 | 761 | s0:space* |
760 | 762 | "=" |
— | — | @@ -1825,5 +1827,8 @@ |
1826 | 1828 | // Special-case support for those pipe templates |
1827 | 1829 | pipe = "|" / "{{!}}" |
1828 | 1830 | |
| 1831 | +// Similar, for tables.. |
| 1832 | +exclam = "!" / "{{;}}" |
| 1833 | + |
1829 | 1834 | /* Tabs do not mix well with the hybrid production syntax */ |
1830 | 1835 | /* vim: set filetype=javascript expandtab ts=4 sw=4 cindent : */ |
Index: trunk/extensions/VisualEditor/modules/parser/ext.core.LinkHandler.js |
— | — | @@ -60,7 +60,9 @@ |
61 | 61 | content.push( tail ); |
62 | 62 | } |
63 | 63 | |
64 | | - obj.attribs.push( new KV('data-mw-type', 'internal') ); |
| 64 | + //obj.attribs.push( new KV('data-mw-type', 'internal') ); |
| 65 | + obj.dataAttribs = token.dataAttribs; |
| 66 | + obj.dataAttribs.linkType = 'internal'; |
65 | 67 | return { |
66 | 68 | tokens: [obj].concat( content, new EndTagTk( 'a' ) ) |
67 | 69 | }; |
— | — | @@ -263,10 +265,10 @@ |
264 | 266 | tokens: |
265 | 267 | [ |
266 | 268 | |
267 | | - new TagTk( 'a', [ |
268 | | - new KV('href', href), |
269 | | - new KV('data-mw-type', 'external') |
270 | | - ] ) |
| 269 | + new TagTk ( 'a', |
| 270 | + [ new KV('href', href) ], |
| 271 | + token.dataAttribs |
| 272 | + ) |
271 | 273 | ].concat( content, [ new EndTagTk( 'a' )]) |
272 | 274 | }; |
273 | 275 | } else { |
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js |
— | — | @@ -120,6 +120,7 @@ |
121 | 121 | ) |
122 | 122 | ) || null; |
123 | 123 | case '{': |
| 124 | + // {{!}} pipe templates.. |
124 | 125 | return ( |
125 | 126 | counters.pipe || |
126 | 127 | counters.template |