Another tokenizer robustness improvement

This patch fixes a tokenizer syntax error encountered on
[[:en:Template:JacksonvilleWikiProject-Member]] and [[:en:Template:Infobox
former country]] by allowing optional whitespace before start-of-line template
syntax.

Change-Id: Ic214a731de58bf766e51f23d5e24ea2ce6788f58
This commit is contained in:
Gabriel Wicke 2012-05-30 18:38:23 +02:00
parent a133768781
commit c5d7e01944
2 changed files with 8 additions and 5 deletions

View file

@ -205,12 +205,15 @@ PegTokenizer.prototype.inline_breaks = function (input, pos, stops ) {
! counters.linkdesc || null;
case "\r":
return stops.onStack( 'table' ) &&
input.substr(pos, 4).match(/\r\n?[!|]/) !== null ||
input.substr(pos).match(/\r\n?\s*[!|]/) !== null ||
null;
case "\n":
return stops.onStack( 'table' ) &&
input[pos + 1] === '!' ||
input[pos + 1] === '|' ||
return ( stops.onStack( 'table' ) &&
// allow leading whitespace in tables
input.substr(pos, 200).match( /^\n\s*[!|]/ ) ) ||
// break on table-like syntax when the table stop is not
// enabled. XXX: see if this can be improved
input.substr(pos, 200).match( /^\n[!|]/ ) ||
null;
case "]":
return stops.onStack( 'extlink' ) ||

View file

@ -1483,7 +1483,7 @@ table_heading_tag
}
table_end_tag
= pipe "}" {
= space* pipe "}" {
var tok = [new EndTagTk( 'table' )];
return tok;
}