Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js |
— | — | @@ -347,7 +347,9 @@ |
348 | 348 | failOutputTests = 0; |
349 | 349 | |
350 | 350 | var postProcessor = new DOMPostProcessor(); |
| 351 | + |
351 | 352 | function processTest(item) { |
| 353 | + // Create a new tree builder, which also creates a new document. |
352 | 354 | var treeBuilder = new FauxHTML5.TreeBuilder(); |
353 | 355 | if (!('title' in item)) { |
354 | 356 | console.log(item); |
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js |
— | — | @@ -15,8 +15,10 @@ |
16 | 16 | this.initSource(function() { |
17 | 17 | var out, err; |
18 | 18 | try { |
19 | | - var parser = PEG.buildParser(PegTokenizer.src); |
20 | | - out = parser.parse(text); |
| 19 | + if ( !this.parser ) { |
| 20 | + this.parser = PEG.buildParser(PegTokenizer.src); |
| 21 | + } |
| 22 | + out = this.parser.parse(text); |
21 | 23 | } catch (e) { |
22 | 24 | err = e; |
23 | 25 | console.trace(); |
Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt |
— | — | @@ -14,6 +14,9 @@ |
15 | 15 | |
16 | 16 | // Flatten a list of lists. |
17 | 17 | var flatten = function ( e ) { |
| 18 | + // Fast single-level flatten: |
| 19 | + //return [].concat.apply([], e); |
| 20 | + |
18 | 21 | var es = []; |
19 | 22 | // flatten sub-arrays |
20 | 23 | for(var i = 0, length = e.length; i < length; i++) { |
— | — | @@ -1016,15 +1019,16 @@ |
1017 | 1020 | } |
1018 | 1021 | |
1019 | 1022 | // http://dev.w3.org/html5/spec/Overview.html#attributes-0, and we also |
1020 | | -// disallow newlines and |. |
| 1023 | +// disallow newlines, | and {. |
1021 | 1024 | generic_attribute_name |
1022 | | - = n:[^ \t\0/"'>=\n|]+ { |
| 1025 | + = n:[^ \t\0/"'>=\n|{]+ { |
1023 | 1026 | return n.join(''); |
1024 | 1027 | } |
1025 | 1028 | |
1026 | 1029 | generic_attribute_value |
1027 | 1030 | = "=" space* v:att_value {return v} |
1028 | 1031 | |
| 1032 | +// XXX: attributes can contain templates and template args!! |
1029 | 1033 | att_value |
1030 | 1034 | = t:[^ \t'"<>='\n]+ { return t.join(''); } |
1031 | 1035 | // XXX: is "\"" also valid html? or just Wikitext? |