From fb9f7a5ea1c3b413aec25f2e0ddba28d1d398888 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Sun, 13 Oct 2024 21:31:51 +0800 Subject: [PATCH] fix: table space and horizrule block new line --- core/modules/parsers/wikiparser/rules/codeblock.js | 2 +- core/modules/parsers/wikiparser/rules/horizrule.js | 2 +- core/modules/parsers/wikiparser/rules/table.js | 10 +++++----- .../test/tiddlers/tests/data/serialize/CodeBlock.tid | 5 +++++ editions/test/tiddlers/tests/data/serialize/Table.tid | 11 +++++++---- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/core/modules/parsers/wikiparser/rules/codeblock.js b/core/modules/parsers/wikiparser/rules/codeblock.js index 99e25af55..aae047316 100644 --- a/core/modules/parsers/wikiparser/rules/codeblock.js +++ b/core/modules/parsers/wikiparser/rules/codeblock.js @@ -58,7 +58,7 @@ exports.parse = function() { }; exports.serialize = function(tree,serialize) { - return "\n```" + tree.attributes.language.value + "\n" + tree.attributes.code.value + "\n```\n"; + return "```" + tree.attributes.language.value + "\n" + tree.attributes.code.value + "\n```\n\n"; } })(); diff --git a/core/modules/parsers/wikiparser/rules/horizrule.js b/core/modules/parsers/wikiparser/rules/horizrule.js index 4fd66de41..386a0aaef 100644 --- a/core/modules/parsers/wikiparser/rules/horizrule.js +++ b/core/modules/parsers/wikiparser/rules/horizrule.js @@ -32,7 +32,7 @@ exports.parse = function() { }; exports.serialize = function(tree,serialize) { - return "---\n"; + return "---\n\n"; } })(); diff --git a/core/modules/parsers/wikiparser/rules/table.js b/core/modules/parsers/wikiparser/rules/table.js index 68811efc0..2c6f4356a 100644 --- a/core/modules/parsers/wikiparser/rules/table.js +++ b/core/modules/parsers/wikiparser/rules/table.js @@ -205,17 +205,17 @@ exports.serialize = function(tree, serialize) { if(cell.tag === "th") { serialized += "!"; } - // Serialize the cell content + // Cell content serialized += serialize(cell.children); - // End the cell with a tailing space - serialized += " |"; + // End the cell + serialized += "|"; } // End the row serialized += "\n"; } } - // Return the complete serialized string - return serialized; + // Return the completed block + return serialized + "\n"; }; })(); diff --git a/editions/test/tiddlers/tests/data/serialize/CodeBlock.tid b/editions/test/tiddlers/tests/data/serialize/CodeBlock.tid index 8b1499970..7a03f3aea 100644 --- a/editions/test/tiddlers/tests/data/serialize/CodeBlock.tid +++ b/editions/test/tiddlers/tests/data/serialize/CodeBlock.tid @@ -9,4 +9,9 @@ Simple `JS` and complex ```js var match = reEnd.exec(this.parser.source) ``` + +```tid +<$list filter="[tag[ExampleTag]sort[title]]"/> +``` + end \ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/serialize/Table.tid b/editions/test/tiddlers/tests/data/serialize/Table.tid index 213ecebff..bd92db4bc 100644 --- a/editions/test/tiddlers/tests/data/serialize/Table.tid +++ b/editions/test/tiddlers/tests/data/serialize/Table.tid @@ -2,7 +2,10 @@ tags: $:/tags/wikitext-serialize-test-spec title: Serialize/Table type: text/vnd.tiddlywiki -|! |!Alpha |!Beta |!Gamma |!Delta | -|!One | | | | | -|!Two | | | | | -|!Three | | | | | \ No newline at end of file +|!|!Alpha|!Beta|!Gamma|!Delta| +|!One||||| +|!Two||||| +|!Three||||| + +|cell one|cell two| +|cell three|cell four|