From a2da94e6576ae1b98ae8a0e4e09d4fb960ebef8b Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Mon, 16 Jul 2012 13:58:00 +0100 Subject: [PATCH] Fixed problem with wikitext macro rule selecting block mode wrongly --- core/modules/parsers/newwikitextparser/rules/macro.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/modules/parsers/newwikitextparser/rules/macro.js b/core/modules/parsers/newwikitextparser/rules/macro.js index 416a893ec..6f5d04c7a 100644 --- a/core/modules/parsers/newwikitextparser/rules/macro.js +++ b/core/modules/parsers/newwikitextparser/rules/macro.js @@ -29,12 +29,22 @@ exports.regExpString = "<<(?:(?:[!@£\\$%\\^\\&\\*\\(\\)`\\~'\"\\|\\\\\\/;\\:\\. exports.parse = function(match,isBlock) { var regExp = /<<(?:([!@£\$%\^\&\*\(\)`\~'"\|\\\/;\:\.\,\+\=\-\_\{\}])|([^>\s]+))(?:\s*)((?:[^>]|(?:>(?!>|<)))*)>(?:(>)|(<))/mg, + reLineBreak = /(\r?\n)/mg, content = []; regExp.lastIndex = this.pos; match = regExp.exec(this.source); if(match && match.index === this.pos) { this.pos = match.index + match[0].length; if(match[5]) { + // Look for a line break immediately after the `><` to trigger block mode + reLineBreak.lastIndex = this.pos; + var lineBreakMatch = reLineBreak.exec(this.source); + if(lineBreakMatch && lineBreakMatch.index === this.pos) { + this.pos = lineBreakMatch.index + lineBreakMatch[0].length; + isBlock = true; + } else { + isBlock = false; + } // If the macro has content then parse it as a block or run if(isBlock) { content = this.parseBlocks(">>");