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(">>");