From 75b041e5623c8a043b02d98f63cc0fbd58971885 Mon Sep 17 00:00:00 2001 From: pmario Date: Sat, 17 Feb 2024 04:31:35 +0100 Subject: [PATCH] wikiparser.js needs to handle child-arrays to check for text-nodes --- core/modules/parsers/wikiparser/wikiparser.js | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/core/modules/parsers/wikiparser/wikiparser.js b/core/modules/parsers/wikiparser/wikiparser.js index 45c4708a2..0d3147de5 100644 --- a/core/modules/parsers/wikiparser/wikiparser.js +++ b/core/modules/parsers/wikiparser/wikiparser.js @@ -242,13 +242,30 @@ WikiParser.prototype.parseBlock = function(terminatorRegExpString) { var children = this.parseInlineRun(terminatorRegExp); var end = this.pos; // return [{type: "element", tag: "p", children: children, start: start, end: end }]; - if (children[0].type === "text" || - (($tw.config.htmlBlockElements.indexOf(children[0].tag) === -1) && children[0] && - children[0].tag && children[0].tag.charAt(0) !== "$")) { + + var isP = false; + $tw.utils.each(children, function(child) { + if (child.type === "text" || + (($tw.config.htmlBlockElements.indexOf(child.tag) === -1) && + child.tag && child.tag.charAt(0) !== "$")) { + isP = true; + } + }); + + if (isP) { return [{type: "element", tag: "p", children: children, start: start, end: end }]; - } else { + } + else { return children; } + + // if (children[0].type === "text" || + // (($tw.config.htmlBlockElements.indexOf(children[0].tag) === -1) && children[0] && + // children[0].tag && children[0].tag.charAt(0) !== "$")) { + // return [{type: "element", tag: "p", children: children, start: start, end: end }]; + // } else { + // return children; + // } }; /*