r106940 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106939‎ | r106940 | r106941 >
Date:11:38, 21 December 2011
Author:gwicke
Status:deferred
Tags:
Comment:
Handle noinclude and includeonly at start of line, so that syntax after it
still matches as if it actually was preceded by a newline.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt
@@ -342,6 +342,8 @@
343343
344344 // Start of line
345345 sol = (newline / & { return pos === 0; } { return true; })
 346+ // Eat multi-line comments, so that syntax after still matches as if it
 347+ // was actually preceded by a newline
346348 cn:(c:comment n:newline? {
347349 if ( n !== '' ) {
348350 return [c, {type: 'TEXT', value: n}];
@@ -349,8 +351,21 @@
350352 return [c];
351353 }
352354 }
353 - )* {
354 - return [{type: 'NEWLINE'}].concat(cn);
 355+ )*
 356+ // Eat includeonly/noinclude at start of line, so that start-of-line
 357+ // syntax after it still matches
 358+ ni:(space* "<" c:"/"? t:("includeonly" / "noinclude") ">" {return [c, t]} )?
 359+ {
 360+ var niToken = [];
 361+ if ( ni !== '') {
 362+ if ( ni[0] === '/' ) {
 363+ niToken = [{type: 'ENDTAG', name: ni[1]}];
 364+ } else {
 365+ niToken = [{type: 'TAG', name: ni[1]}];
 366+ }
 367+ }
 368+
 369+ return [{type: 'NEWLINE'}].concat(cn, niToken);
355370 }
356371
357372 eof = & { return isEOF(pos); } { return true; }
@@ -419,9 +434,6 @@
420435 / pre
421436
422437
423 -
424 -
425 -// TODO: convert inline content to annotations!
426438 para
427439 = s1:sol s2:sol c:inlineline {
428440 return s1.concat(s2, [{type: 'TAG', name: 'p'}], c);

Status & tagging log