diff --git a/core/modules/parsers/wikiparser/rules/image.js b/core/modules/parsers/wikiparser/rules/image.js index 33454f46e..f046c59f1 100644 --- a/core/modules/parsers/wikiparser/rules/image.js +++ b/core/modules/parsers/wikiparser/rules/image.js @@ -131,10 +131,8 @@ exports.parseImage = function(source,pos) { }; exports.serialize = function(tree) { - // DEBUG: console tree - console.warn(`tree`, JSON.stringify(tree, null, ' ')); - var width = tree.attributes.width ? " width=" + tree.attributes.width.value : ""; - var height = tree.attributes.height ? " height=" + tree.attributes.height.value : ""; + var width = tree.attributes.width ? " " + $tw.utils.serializeAttribute(tree.attributes.width) : ""; + var height = tree.attributes.height ? " " + $tw.utils.serializeAttribute(tree.attributes.height) : ""; var padSpace = width || height ? " " : ""; var tooltip = tree.attributes.tooltip ? tree.attributes.tooltip.value + "|" : ""; var source = tree.attributes.source.value; diff --git a/editions/test/tiddlers/tests/test-wikitext-serialize.js b/editions/test/tiddlers/tests/test-wikitext-serialize.js index 69800a81f..8e73c8ef9 100644 --- a/editions/test/tiddlers/tests/test-wikitext-serialize.js +++ b/editions/test/tiddlers/tests/test-wikitext-serialize.js @@ -207,7 +207,7 @@ describe('WikiAST serialization unit tests', function () { wiki.addTiddler({ title: 'ImageTest', - text: '[img[https://tiddlywiki.com/fractalveg.jpg]]\n[img width=23 height=24 [https://tiddlywiki.com/fractalveg.jpg]]\n[img width={{!!width}} height={{!!height}} [https://tiddlywiki.com/fractalveg.jpg]]\n[img[Description of image|https://tiddlywiki.com/fractalveg.jpg]]\n[img[TiddlerTitle]]\n[img[Description of image|TiddlerTitle]]', + text: '[img[https://tiddlywiki.com/fractalveg.jpg]]\n[img width="23" height="24" [https://tiddlywiki.com/fractalveg.jpg]]\n[img width={{!!width}} height={{!!height}} [https://tiddlywiki.com/fractalveg.jpg]]\n[img[Description of image|https://tiddlywiki.com/fractalveg.jpg]]\n[img[TiddlerTitle]]\n[img[Description of image|TiddlerTitle]]', }); it('should serialize image tags correctly', function () { var serialized = $tw.utils.serializeParseTree(wiki.parseTiddler('ImageTest').tree).trimEnd();