1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-30 05:19:57 +00:00

fix: macro in widget param

This commit is contained in:
lin onetwo 2024-10-13 20:55:03 +08:00
parent 375df47b19
commit 53296a484c
3 changed files with 17 additions and 5 deletions

View File

@ -405,8 +405,15 @@ exports.serializeAttribute = function(node) {
} else if(node.type === "substituted") {
attributeString += "=`" + node.rawValue + "`";
} else if(node.type === "macro") {
// Assuming macro serialization is complex and handled elsewhere
attributeString += "=" + node.value.serialize();
if(node.value && typeof node.value === "object" && node.value.type === "macrocall") {
var params = node.value.params.map(function(param) {
return param.value;
}).join(" ");
attributeString += "=<<" + node.value.name + " " + params + ">>";
} else {
// Unsupported macro structure
return null;
}
} else {
// Unsupported type
return null;

View File

@ -197,9 +197,9 @@ exports.isLegalTag = function(tag) {
exports.serialize = function(tree, serialize) {
var tag = tree.tag;
var attributes = Object.keys(tree.attributes).map(function(key) {
return key + '="' + tree.attributes[key].value + '"';
}).join("");
var attributes = tree.orderedAttributes.map(function(attribute) {
return $tw.utils.serializeAttribute(attribute);
}).join(" ");
// Children
var children = tree.children ? serialize(tree.children) : "";
// Self-closing tag

View File

@ -0,0 +1,5 @@
tags: $:/tags/wikitext-serialize-test-spec
title: Serialize/Attribute
type: text/vnd.tiddlywiki
<$macrocall $name="rpn" a=<<rpn 2 2 *>> b="pi" operation="*" decimals="4" />