From 4c7dcb83d1c942f61b811adb606c00896140dec2 Mon Sep 17 00:00:00 2001 From: Cameron Fischer Date: Fri, 29 Jan 2021 09:57:30 -0500 Subject: [PATCH] Fix for #3306, inline/block widget glitch (#5452) * Fix for #3306, inline/block widget glitch * Just realized we don't need to set lastIndex anymore * Forgot that parseBlocks doesn't use options --- core/modules/parsers/wikiparser/rules/html.js | 11 +++-------- editions/test/tiddlers/tests/test-wikitext-parser.js | 6 ++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/core/modules/parsers/wikiparser/rules/html.js b/core/modules/parsers/wikiparser/rules/html.js index b92d19a69..b9e6bdc69 100644 --- a/core/modules/parsers/wikiparser/rules/html.js +++ b/core/modules/parsers/wikiparser/rules/html.js @@ -53,17 +53,12 @@ exports.parse = function() { tag.isBlock = this.is.block || hasLineBreak; // Parse the body if we need to if(!tag.isSelfClosing && $tw.config.htmlVoidElements.indexOf(tag.tag) === -1) { - var reEndString = "", - reEnd = new RegExp("(" + reEndString + ")","mg"); + var reEndString = ""; if(hasLineBreak) { tag.children = this.parser.parseBlocks(reEndString); } else { - tag.children = this.parser.parseInlineRun(reEnd); - } - reEnd.lastIndex = this.parser.pos; - var endMatch = reEnd.exec(this.parser.source); - if(endMatch && endMatch.index === this.parser.pos) { - this.parser.pos = endMatch.index + endMatch[0].length; + var reEnd = new RegExp("(" + reEndString + ")","mg"); + tag.children = this.parser.parseInlineRun(reEnd,{eatTerminator: true}); } } // Return the tag diff --git a/editions/test/tiddlers/tests/test-wikitext-parser.js b/editions/test/tiddlers/tests/test-wikitext-parser.js index 12607a29f..ea17ff857 100644 --- a/editions/test/tiddlers/tests/test-wikitext-parser.js +++ b/editions/test/tiddlers/tests/test-wikitext-parser.js @@ -103,6 +103,12 @@ describe("WikiText parser tests", function() { [ { type : 'element', tag : 'p', children : [ { type : 'element', start : 0, attributes : { }, tag : 'div', end : 5, isBlock : false, children : [ { type : 'element', start : 5, attributes : { attribute : { start : 9, name : 'attribute', type : 'indirect', textReference : 'TiddlerTitle!!field', end : 43 } }, tag : 'div', end : 44, isBlock : false, children : [ { type : 'text', text : '\n!some heading' } ] } ] } ] } ] ); + // Regression test for issue (#3306) + expect(parse("
\n\nSome text
")).toEqual( + + [ { type : 'element', tag : 'p', children : [ { type : 'element', start : 0, attributes : { }, tag : 'div', end : 5, isBlock : false, children : [ { type : 'element', start : 5, attributes : { }, tag : 'span', end : 11, isBlock : false, children : [ { type : 'element', start : 11, attributes : { }, tag : 'span', end : 17, isBlock : true, children : [ { type : 'element', tag : 'p', children : [ { type : 'text', text : 'Some text' } ] } ] } ] } ] } ] } ] + + ); }); it("should parse macro definitions", function() {