Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.templateEditor.js |
— | — | @@ -331,11 +331,12 @@ |
332 | 332 | divider = sanatizedStr.length; |
333 | 333 | doneParsing = true; |
334 | 334 | } |
335 | | - nameMatch = wikitext.substring( oldDivider, divider ).match( /[^{\s]+/ ); |
| 335 | + nameMatch = wikitext.substring( 0, divider ).match( /[^{\s]+/ ); |
336 | 336 | if ( nameMatch != undefined ) { |
337 | | - ranges.push( new Range( oldDivider,nameMatch.index ) ); //whitespace and squiggles upto the name |
| 337 | + ranges.push( new Range( 0 ,nameMatch.index ) ); //whitespace and squiggles upto the name |
| 338 | + nameEndMatch = sanatizedStr.substring( 0 , divider ).match( /[^\s]\s*$/ ); //last nonwhitespace character |
338 | 339 | templateNameIndex = ranges.push( new Range( nameMatch.index, |
339 | | - nameMatch.index + nameMatch[0].length ) ); |
| 340 | + nameEndMatch.index + 1 ) ); |
340 | 341 | templateNameIndex--; //push returns 1 less than the array |
341 | 342 | ranges[templateNameIndex].old = wikitext.substring( ranges[templateNameIndex].begin, |
342 | 343 | ranges[templateNameIndex].end ); |
— | — | @@ -359,7 +360,7 @@ |
360 | 361 | if ( currentField.indexOf( '=' ) == -1 ) { |
361 | 362 | // anonymous field, gets a number |
362 | 363 | valueBegin = currentField.match( /\S+/ ); //first nonwhitespace character |
363 | | - valueBeginIndex = valueBegin.index + oldDivider + 1; |
| 364 | + valueBeginIndex = valueBegin.index + oldDivider+1; |
364 | 365 | valueEnd = currentField.match( /[^\s]\s*$/ ); //last nonwhitespace character |
365 | 366 | valueEndIndex = valueEnd.index + oldDivider + 2; |
366 | 367 | ranges.push( new Range( ranges[ranges.length-1].end, |
— | — | @@ -383,7 +384,6 @@ |
384 | 385 | nameBegin = currentName.match( /\S+/ ); |
385 | 386 | if ( nameBegin == null ) { |
386 | 387 | // This is a comment inside a template call / parser abuse. let's not encourage it |
387 | | - divider++; |
388 | 388 | currentParamNumber--; |
389 | 389 | continue; |
390 | 390 | } |