diff --git a/core/modules/parsers/parseutils.js b/core/modules/parsers/parseutils.js index fcc96b2de..e2e95c684 100644 --- a/core/modules/parsers/parseutils.js +++ b/core/modules/parsers/parseutils.js @@ -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; diff --git a/core/modules/parsers/wikiparser/rules/html.js b/core/modules/parsers/wikiparser/rules/html.js index df52819e2..e27089086 100644 --- a/core/modules/parsers/wikiparser/rules/html.js +++ b/core/modules/parsers/wikiparser/rules/html.js @@ -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 diff --git a/editions/test/tiddlers/tests/data/serialize/Attribute.tid b/editions/test/tiddlers/tests/data/serialize/Attribute.tid new file mode 100644 index 000000000..6ecda2c01 --- /dev/null +++ b/editions/test/tiddlers/tests/data/serialize/Attribute.tid @@ -0,0 +1,5 @@ +tags: $:/tags/wikitext-serialize-test-spec +title: Serialize/Attribute +type: text/vnd.tiddlywiki + +<$macrocall $name="rpn" a=<> b="pi" operation="*" decimals="4" />