From e3a745a0247632be3b71bde005177c4d5e0a751a Mon Sep 17 00:00:00 2001 From: Gabriel Wicke Date: Wed, 4 Apr 2012 16:29:47 +0200 Subject: [PATCH] Improvements for template / -argument precedence; support for empty params Change-Id: Id0894ccbedfa47fa3658817ca65119a2af76be3e --- modules/parser/mediawiki.parser.environment.js | 6 +++++- modules/parser/pegTokenizer.pegjs.txt | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/parser/mediawiki.parser.environment.js b/modules/parser/mediawiki.parser.environment.js index a30b27bfdd..efef63cb69 100644 --- a/modules/parser/mediawiki.parser.environment.js +++ b/modules/parser/mediawiki.parser.environment.js @@ -300,7 +300,11 @@ MWParserEnvironment.prototype.sanitizeURI = function ( s ) { MWParserEnvironment.prototype.dp = function ( ) { if ( this.debug ) { if ( arguments.length > 1 ) { - console.warn( JSON.stringify( arguments, null, 2 ) ); + try { + console.warn( JSON.stringify( arguments, null, 2 ) ); + } catch ( e ) { + console.warn( e ); + } } else { console.warn( arguments[0] ); } diff --git a/modules/parser/pegTokenizer.pegjs.txt b/modules/parser/pegTokenizer.pegjs.txt index a32aecd156..d5853acc9e 100644 --- a/modules/parser/pegTokenizer.pegjs.txt +++ b/modules/parser/pegTokenizer.pegjs.txt @@ -830,8 +830,8 @@ ipv6_address tplarg_or_template = ! '{{{{{{{' ( - &'{{{{{{' tplarg - / & '{{{{{' template + & ( '{{{{{{' (!'}}}' .)* '}}}}}}') tplarg + / & ( '{{{{{' (!'}}}' .)* '}}}}}') template / tplarg / template ) @@ -840,7 +840,7 @@ template = "{{" (newline / space)* target:template_name params:(( newline / space )* "|" - r:( &"|" { return new KV( '', '') } // empty argument + r:( (newline / space )* &"|" { return new KV( '', '') } // empty argument / p:template_param { return p } ) { return r } )*