From c39297698f995798d96809a23270ef665bd2c34f Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Sun, 4 Aug 2024 00:48:29 +0800 Subject: [PATCH] fix: render invisible comment and parsemode as data element --- core/modules/parsers/wikiparser/rules/commentblock.js | 3 ++- core/modules/parsers/wikiparser/rules/commentinline.js | 3 ++- core/modules/parsers/wikiparser/rules/macrodef.js | 2 +- core/modules/parsers/wikiparser/rules/parameters.js | 2 +- core/modules/parsers/wikiparser/rules/parsermode.js | 3 ++- core/modules/utils/parsetree.js | 2 +- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/core/modules/parsers/wikiparser/rules/commentblock.js b/core/modules/parsers/wikiparser/rules/commentblock.js index 0fc3c0422..56a0857dd 100644 --- a/core/modules/parsers/wikiparser/rules/commentblock.js +++ b/core/modules/parsers/wikiparser/rules/commentblock.js @@ -55,7 +55,8 @@ exports.parse = function() { var commentEnd = this.endMatch.index + this.endMatch[0].length; var commentText = this.parser.source.slice(commentStart, commentEnd); return [{ - type: "commentblock", + type: "element", + tag: "data", text: commentText, start: commentStart, end: commentEnd diff --git a/core/modules/parsers/wikiparser/rules/commentinline.js b/core/modules/parsers/wikiparser/rules/commentinline.js index 50e861fe4..5ddcd8c82 100644 --- a/core/modules/parsers/wikiparser/rules/commentinline.js +++ b/core/modules/parsers/wikiparser/rules/commentinline.js @@ -48,7 +48,8 @@ exports.parse = function() { var commentEnd = this.endMatch.index + this.endMatch[0].length; var commentText = this.parser.source.slice(commentStart, commentEnd); return [{ - type: "commentinline", + type: "element", + tag: "data", text: commentText, start: commentStart, end: commentEnd diff --git a/core/modules/parsers/wikiparser/rules/macrodef.js b/core/modules/parsers/wikiparser/rules/macrodef.js index 735c7958a..9dec07682 100644 --- a/core/modules/parsers/wikiparser/rules/macrodef.js +++ b/core/modules/parsers/wikiparser/rules/macrodef.js @@ -89,7 +89,7 @@ exports.parse = function() { return parseTreeNodes; }; -exports.serialize = function(tree) { +exports.serialize = function(tree,serialize) { // Macro name var name = tree.attributes.name.value; // Parameters diff --git a/core/modules/parsers/wikiparser/rules/parameters.js b/core/modules/parsers/wikiparser/rules/parameters.js index ddb3a65ab..6be51c24b 100644 --- a/core/modules/parsers/wikiparser/rules/parameters.js +++ b/core/modules/parsers/wikiparser/rules/parameters.js @@ -57,7 +57,7 @@ exports.parse = function() { }]; }; -exports.serialize = function(tree) { +exports.serialize = function(tree,serialize) { // Parameters var params = tree.orderedAttributes.map(function(param) { return param.name + (param.value ? ":" + param.value : ""); diff --git a/core/modules/parsers/wikiparser/rules/parsermode.js b/core/modules/parsers/wikiparser/rules/parsermode.js index c5ec0fdd1..713bb36ed 100644 --- a/core/modules/parsers/wikiparser/rules/parsermode.js +++ b/core/modules/parsers/wikiparser/rules/parsermode.js @@ -63,7 +63,8 @@ exports.parse = function() { } } return [{ - type: "parsermode", + type: "element", + tag: "data", parseAsInline: this.parser.parseAsInline, start: start, end: this.parser.pos diff --git a/core/modules/utils/parsetree.js b/core/modules/utils/parsetree.js index 76ff385f0..670d6307b 100644 --- a/core/modules/utils/parsetree.js +++ b/core/modules/utils/parsetree.js @@ -133,7 +133,7 @@ exports.serializeParseTree = function serializeParseTree(tree,tiddlerType) { $tw.utils.each(tree,function(node) { output.push(serializeParseTree(node,tiddlerType)); }); - } else { + } else if(tree) { if(tree.type === "text" && !tree.rule) { output.push(tree.text); } else {