1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-06-05 12:12:23 +00:00

fix: link may not have attribute and children

This commit is contained in:
linonetwo
2025-02-19 18:58:33 +08:00
parent 87dc05be9d
commit 2765e995dd
2 changed files with 5 additions and 5 deletions
@@ -51,11 +51,11 @@ exports.parse = function() {
};
exports.serialize = function(tree,serialize) {
// Check if the link is suppressed
var isSuppressed = tree.children[0].text.substr(0,1) === "~";
// Check if the link is suppressed. Tree may only have text, no children and attributes
var isSuppressed = tree.children && tree.children[0].text.substr(0,1) === "~";
var serialized = isSuppressed ? "~" : "";
// Append the link text
serialized += tree.attributes.to.value;
serialized += tree.attributes ? tree.attributes.to.value : tree.text;
return serialized;
};
@@ -66,10 +66,10 @@ exports.parse = function() {
};
exports.serialize = function(tree,serialize) {
var isSuppressed = tree.children[0].text.substr(0,1) === $tw.config.textPrimitives.unWikiLink;
var isSuppressed = tree.children && tree.children[0].text.substr(0,1) === $tw.config.textPrimitives.unWikiLink;
var serialized = isSuppressed ? $tw.config.textPrimitives.unWikiLink : "";
serialized += tree.attributes.to.value;
serialized += tree.attributes ? tree.attributes.to.value : tree.text;
return serialized;
};