diff --git a/core/modules/parsers/newwikitextparser/newwikitextparser.js b/core/modules/parsers/newwikitextparser/newwikitextparser.js index 74ad1aa45..a9fa9931d 100644 --- a/core/modules/parsers/newwikitextparser/newwikitextparser.js +++ b/core/modules/parsers/newwikitextparser/newwikitextparser.js @@ -65,6 +65,39 @@ WikiTextRenderer.prototype.parseBlock = function() { } }; +/* +Parse blocks of text until a terminating regexp is encountered + terminatorRegExp: terminating regular expression + addClass: optional CSS class to add to each block +*/ +WikiTextRenderer.prototype.parseBlockTerminated = function(terminatorRegExp,className) { + var tree = []; + // Skip any whitespace + this.skipWhitespace(); + // Check if we've got the end marker + terminatorRegExp.lastIndex = this.pos; + var match = terminatorRegExp.exec(this.source); + // Parse the text into blocks + while(this.pos < this.sourceLength && !(match && match.index === this.pos)) { + var blocks = this.parseBlock(); + for(var t=0; t