From 078967c830ad26a145c01bb41808f8fc24787f38 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Tue, 30 Jul 2024 00:56:28 +0800 Subject: [PATCH] feat: allow recursive --- core/modules/parsers/wikiparser/rules/codeblock.js | 2 +- core/modules/parsers/wikiparser/rules/codeinline.js | 4 ++-- core/modules/parsers/wikiparser/rules/horizrule.js | 2 +- core/modules/utils/parsetree.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/modules/parsers/wikiparser/rules/codeblock.js b/core/modules/parsers/wikiparser/rules/codeblock.js index 11681261b..99e25af55 100644 --- a/core/modules/parsers/wikiparser/rules/codeblock.js +++ b/core/modules/parsers/wikiparser/rules/codeblock.js @@ -57,7 +57,7 @@ exports.parse = function() { }]; }; -exports.serialize = function(tree) { +exports.serialize = function(tree,serialize) { return "\n```" + tree.attributes.language.value + "\n" + tree.attributes.code.value + "\n```\n"; } diff --git a/core/modules/parsers/wikiparser/rules/codeinline.js b/core/modules/parsers/wikiparser/rules/codeinline.js index a78b56e6b..4d32089ab 100644 --- a/core/modules/parsers/wikiparser/rules/codeinline.js +++ b/core/modules/parsers/wikiparser/rules/codeinline.js @@ -55,8 +55,8 @@ exports.parse = function() { }]; }; -exports.serialize = function(tree) { - return "`" + tree.children[0].text + "`"; +exports.serialize = function(tree,serialize) { + return "`" + serialize(tree.children) + "`"; } })(); diff --git a/core/modules/parsers/wikiparser/rules/horizrule.js b/core/modules/parsers/wikiparser/rules/horizrule.js index e9279a4d7..4fd66de41 100644 --- a/core/modules/parsers/wikiparser/rules/horizrule.js +++ b/core/modules/parsers/wikiparser/rules/horizrule.js @@ -31,7 +31,7 @@ exports.parse = function() { return [{type: "element", tag: "hr"}]; }; -exports.serialize = function() { +exports.serialize = function(tree,serialize) { return "---\n"; } diff --git a/core/modules/utils/parsetree.js b/core/modules/utils/parsetree.js index f5b2c12d0..e825cd747 100644 --- a/core/modules/utils/parsetree.js +++ b/core/modules/utils/parsetree.js @@ -131,7 +131,7 @@ exports.serializeParseTree = function serializeParseTree(tree,tiddlerType) { var output = []; if($tw.utils.isArray(tree)) { $tw.utils.each(tree,function(node) { - output.push(serializeParseTree(node)); + output.push(serializeParseTree(node,tiddlerType)); }); } else { if(tree.type === "text") {