Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt |
— | — | @@ -415,13 +415,24 @@ |
416 | 416 | * |
417 | 417 | * XXX: Repeated testing of flags is not terribly efficient. |
418 | 418 | */ |
419 | | -inline_breaks |
| 419 | + |
| 420 | +inline_breaks_ = |
| 421 | + & [=|!}:\r\n\]<] |
| 422 | + & { cacheKey = ''; ilbpos = pos; return true; } |
| 423 | + res:inline_breaks_o |
| 424 | +{ |
| 425 | + console.warn( 'ilbo res: ' + JSON.stringify( [ res, input.substr( ilbpos, 4 ) ] ) ); |
| 426 | + return res; |
| 427 | +} |
| 428 | + |
| 429 | + |
| 430 | +inline_breaks_o |
420 | 431 | = & [=|!}:\r\n\]<] // don't check further if char cannot match |
421 | 432 | res:( |
422 | 433 | & { // Important hack: disable caching for this production, as the default |
423 | 434 | // cache key does not take into account flag states! |
424 | 435 | cacheKey = ''; |
425 | | - console.warn('ilb: ' + input.substr(pos, 5) ); |
| 436 | + //console.warn('ilb: ' + input.substr(pos, 5) ); |
426 | 437 | return true; |
427 | 438 | } |
428 | 439 | |
— | — | @@ -453,16 +464,14 @@ |
454 | 465 | } |
455 | 466 | ) { return res } |
456 | 467 | |
457 | | -inline_breaks_experiment |
| 468 | +inline_breaks |
458 | 469 | = & [=|!}:\r\n\]<] |
459 | 470 | & { // Important hack: disable caching for this production, as the default |
460 | 471 | // cache key does not take into account flag states! |
461 | 472 | cacheKey = ''; |
462 | 473 | //console.warn('ilbf: ' + input.substr(pos, 5) ); |
463 | | - return true; |
| 474 | + return null !== __parseArgs[3].inline_breaks( input, pos, syntaxFlags ) |
464 | 475 | } |
465 | | - . |
466 | | - { return __parseArgs[3].inline_breaks( input, pos - 1, syntaxFlags ) && true || null ; } |
467 | 476 | |
468 | 477 | inline |
469 | 478 | = c:(urltext / (! inline_breaks (inline_element / . )))+ { |
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.tokenizer.peg.js |
— | — | @@ -101,14 +101,13 @@ |
102 | 102 | }, |
103 | 103 | "\r": function ( input, pos, syntaxFlags ) { |
104 | 104 | return syntaxFlags.table && |
105 | | - input[pos + 1] !== '!' && |
106 | | - input[pos + 1] !== '|' || |
| 105 | + input.substr(pos, 4).match(/\r\n?[!|]/) !== null || |
107 | 106 | null; |
108 | 107 | }, |
109 | 108 | "\n": function ( input, pos, syntaxFlags ) { |
110 | 109 | return syntaxFlags.table && |
111 | | - input[pos + 1] !== '!' && |
112 | | - input[pos + 1] !== '|' || |
| 110 | + input[pos + 1] === '!' || |
| 111 | + input[pos + 1] === '|' || |
113 | 112 | null; |
114 | 113 | }, |
115 | 114 | "]": function ( input, pos, syntaxFlags ) { |
— | — | @@ -121,12 +120,56 @@ |
122 | 121 | } |
123 | 122 | }; |
124 | 123 | |
| 124 | +PegTokenizer.prototype.inline_breaks_ = function (input, pos, syntaxFlags ) { |
| 125 | + return this.breakMap[ input[pos] ]( input, pos, syntaxFlags); |
| 126 | + //console.warn( 'ilbn res: ' + JSON.stringify( [ res, input.substr( pos, 4 ) ] ) ); |
| 127 | + //return res; |
| 128 | +}; |
| 129 | + |
125 | 130 | PegTokenizer.prototype.inline_breaks = function (input, pos, syntaxFlags ) { |
126 | | - var res = this.breakMap[ input[pos] ]( input, pos, syntaxFlags); |
127 | | - console.warn( 'ilb res: ' + JSON.stringify( [ res, input.substr( pos, 4 ) ] ) ); |
128 | | - return res; |
| 131 | + switch( input[pos] ) { |
| 132 | + case '=': |
| 133 | + return syntaxFlags.equal || |
| 134 | + ( syntaxFlags.h && |
| 135 | + input.substr( pos + 1, 200) |
| 136 | + .match(/[ \t]*[\r\n]/) !== null ) || null; |
| 137 | + case '|': |
| 138 | + return syntaxFlags.template || |
| 139 | + ( syntaxFlags.table && |
| 140 | + ( input[pos + 1].match(/[|}]/) !== null || |
| 141 | + syntaxFlags.tableCellArg |
| 142 | + ) |
| 143 | + ) || null; |
| 144 | + case "!": |
| 145 | + return syntaxFlags.table && input[pos + 1] === "!" || |
| 146 | + null; |
| 147 | + case "}": |
| 148 | + return syntaxFlags.template && input[pos + 1] === "}" || null; |
| 149 | + case ":": |
| 150 | + return syntaxFlags.colon && |
| 151 | + ! syntaxFlags.extlink && |
| 152 | + ! syntaxFlags.linkdesc || null; |
| 153 | + case "\r": |
| 154 | + return syntaxFlags.table && |
| 155 | + input.substr(pos, 4).match(/\r\n?[!|]/) !== null || |
| 156 | + null; |
| 157 | + case "\n": |
| 158 | + return syntaxFlags.table && |
| 159 | + input[pos + 1] === '!' || |
| 160 | + input[pos + 1] === '|' || |
| 161 | + null; |
| 162 | + case "]": |
| 163 | + return syntaxFlags.extlink || |
| 164 | + ( syntaxFlags.linkdesc && input[pos + 1] === ']' ) || |
| 165 | + null; |
| 166 | + case "<": |
| 167 | + return syntaxFlags.pre && input.substr( pos, 6 ) === '</pre>' || null; |
| 168 | + default: |
| 169 | + return null; |
| 170 | + } |
129 | 171 | }; |
130 | 172 | |
| 173 | + |
131 | 174 | /***************************************************************************** |
132 | 175 | * LEGACY stuff |
133 | 176 | * |