From 47cc03d05db1c07e124f54347299274c061dc5b9 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Sun, 13 Oct 2024 21:36:35 +0800 Subject: [PATCH] feat: make sure block rule all have \n\n for visiblity --- .../parsers/wikiparser/rules/conditional.js | 2 +- .../rules/filteredtranscludeblock.js | 2 +- .../parsers/wikiparser/rules/heading.js | 2 +- .../parsers/wikiparser/rules/quoteblock.js | 2 +- .../serialize/FilteredTranscludeBlock.tid | 6 +++++- .../tiddlers/tests/data/serialize/Heading.tid | 21 ++++++++++++++++++- 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/core/modules/parsers/wikiparser/rules/conditional.js b/core/modules/parsers/wikiparser/rules/conditional.js index 84ac3cef8..6f884de1c 100644 --- a/core/modules/parsers/wikiparser/rules/conditional.js +++ b/core/modules/parsers/wikiparser/rules/conditional.js @@ -139,7 +139,7 @@ exports.serialize = function(tree, serialize) { } serialized += "<%endif%>"; - return serialized; + return serialized += "\n\n"; }; })(); diff --git a/core/modules/parsers/wikiparser/rules/filteredtranscludeblock.js b/core/modules/parsers/wikiparser/rules/filteredtranscludeblock.js index 994596855..553d68c0e 100644 --- a/core/modules/parsers/wikiparser/rules/filteredtranscludeblock.js +++ b/core/modules/parsers/wikiparser/rules/filteredtranscludeblock.js @@ -83,7 +83,7 @@ exports.serialize = function(tree, serialize) { serialized += "}" // CSS classes if(tree.attributes.itemClass) serialized += "." + tree.attributes.itemClass.value.split(" ").join("."); - return serialized + "\n"; + return serialized + "\n\n"; }; })(); diff --git a/core/modules/parsers/wikiparser/rules/heading.js b/core/modules/parsers/wikiparser/rules/heading.js index 67470c9c5..70b58e71d 100644 --- a/core/modules/parsers/wikiparser/rules/heading.js +++ b/core/modules/parsers/wikiparser/rules/heading.js @@ -51,7 +51,7 @@ exports.serialize = function(tree, serialize) { var headingLevel = parseInt(tree.tag.substr(1),10); var classes = tree.attributes.class ? tree.attributes.class.value.split(" ").join(".") : ""; var headingText = serialize(tree.children); - return Array(headingLevel + 1).join("!") + (classes ? "." + classes : "") + " " + headingText + "\n"; + return Array(headingLevel + 1).join("!") + (classes ? "." + classes : "") + " " + headingText + "\n\n"; }; })(); diff --git a/core/modules/parsers/wikiparser/rules/quoteblock.js b/core/modules/parsers/wikiparser/rules/quoteblock.js index be7052795..a652cdf1b 100644 --- a/core/modules/parsers/wikiparser/rules/quoteblock.js +++ b/core/modules/parsers/wikiparser/rules/quoteblock.js @@ -85,7 +85,7 @@ exports.serialize = function (tree, serialize) { }); result.push("<<<"); } - return result.join("\n"); + return result.join("\n") + "\n\n"; }; })(); diff --git a/editions/test/tiddlers/tests/data/serialize/FilteredTranscludeBlock.tid b/editions/test/tiddlers/tests/data/serialize/FilteredTranscludeBlock.tid index cbfc442c5..b1c526d9d 100644 --- a/editions/test/tiddlers/tests/data/serialize/FilteredTranscludeBlock.tid +++ b/editions/test/tiddlers/tests/data/serialize/FilteredTranscludeBlock.tid @@ -3,7 +3,11 @@ title: Serialize/FilteredTranscludeBlock type: text/vnd.tiddlywiki {{{ [tag[docs]] }}} + {{{ [tag[docs]] |tooltip}}} + {{{ [tag[docs]] ||TemplateTitle}}} + {{{ [tag[docs]] |tooltip||TemplateTitle}}} -{{{ [tag[docs]] }}width:40;height:50;}.class.class \ No newline at end of file + +{{{ [tag[docs]] }}width:40;height:50;}.class.class diff --git a/editions/test/tiddlers/tests/data/serialize/Heading.tid b/editions/test/tiddlers/tests/data/serialize/Heading.tid index 8f90e379a..34152e50a 100644 --- a/editions/test/tiddlers/tests/data/serialize/Heading.tid +++ b/editions/test/tiddlers/tests/data/serialize/Heading.tid @@ -3,8 +3,27 @@ title: Serialize/Heading type: text/vnd.tiddlywiki ! Heading 1 + !! Heading 2 + !!! Heading 3 + !!!! Heading 4 + !!!!! Heading 5 -!!!!!! Heading 6 \ No newline at end of file + +!!!!!! Heading 6 + +! AAA + +!! AAA + +!!! AAA + +!!!! AAA + +!!!!! AAA + +!!!!!! AAA + +AAA