1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-05 23:10:28 +00:00

fix: use "" for string param

This commit is contained in:
lin onetwo 2024-08-03 20:29:55 +08:00
parent 63613ceec0
commit 7b4ea476f3
2 changed files with 3 additions and 5 deletions

View File

@ -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;

View File

@ -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();