From 8c9812ec9c00320d7d36dfd5d4c1b4433b5aca04 Mon Sep 17 00:00:00 2001 From: pmario Date: Fri, 15 Mar 2024 22:22:49 +0100 Subject: [PATCH] wikiparser - some more adjustments for wikdgets that create DOM elements: button, radio, checkbox, link -- In HTML they are inline, but for backwards compatibility they need to be covered in P tags :/ --- core/modules/parsers/wikiparser/wikiparser.js | 25 ++++++++++++++++--- .../tw5.com/tiddlers/power Operator-todo.tid | 13 ++++++++-- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/core/modules/parsers/wikiparser/wikiparser.js b/core/modules/parsers/wikiparser/wikiparser.js index 0d3147de5..fc123772b 100644 --- a/core/modules/parsers/wikiparser/wikiparser.js +++ b/core/modules/parsers/wikiparser/wikiparser.js @@ -244,15 +244,34 @@ WikiParser.prototype.parseBlock = function(terminatorRegExpString) { // return [{type: "element", tag: "p", children: children, start: start, end: end }]; 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; + // } + // }); + $tw.utils.each(children, function(child) { - if (child.type === "text" || + if(child.type === "text" || (($tw.config.htmlBlockElements.indexOf(child.tag) === -1) && - child.tag && child.tag.charAt(0) !== "$")) { + child.tag && child.tag.charAt(0) !== "$") || + (child.type === "button") || + (child.type === "radio") || + (child.type === "link") || + (child.type === "checkbox") ) { isP = true; } }); - if (isP) { + // $tw.utils.each(children, function(child) { + // if(child.type === "text" || + // (($tw.config.htmlBlockElements.indexOf(child.tag) === -1) ) ) { + // isP = true; + // } + // }); + + if(isP) { return [{type: "element", tag: "p", children: children, start: start, end: end }]; } else { diff --git a/editions/tw5.com/tiddlers/power Operator-todo.tid b/editions/tw5.com/tiddlers/power Operator-todo.tid index 0b7c88b4c..fad38eaa1 100644 --- a/editions/tw5.com/tiddlers/power Operator-todo.tid +++ b/editions/tw5.com/tiddlers/power Operator-todo.tid @@ -1,5 +1,5 @@ created: 20221123151255885 -modified: 20221123151420696 +modified: 20240315205833043 tags: title: power Operator-todo type: text/vnd.tiddlywiki @@ -8,4 +8,13 @@ type: text/vnd.tiddlywiki text and links .. all text is widget created ... Investigate in more detail. vertical spacing -''have a closer look at the DOM structure'' \ No newline at end of file +''have a closer look at the DOM structure'' + +`.operator-examples` is implemented like this: + +``` +\procedure .operator-examples(op,text:"Examples") <$link to=`$(op)$ Operator (Examples)`><> +``` + +So it is implemented as an `` element which is "inline". So if `<<.operator-examples "power">> ` is followed by a space it will add a paragraph -- hmmm +