From 440170aadc1da0b83cf45c84486cb1b140fbfb65 Mon Sep 17 00:00:00 2001 From: ggboy-shakalaka Date: Tue, 26 Apr 2022 01:43:58 +0800 Subject: [PATCH] fix(makemarkdown.image): fix bug width|height = auto `` transforms into `![null]( =autoxauto)`. After fix, the output becomes `![null]( =*x*)` Closes #622 --- src/subParsers/makemarkdown/image.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/subParsers/makemarkdown/image.js b/src/subParsers/makemarkdown/image.js index b5fa039..fd2b967 100644 --- a/src/subParsers/makemarkdown/image.js +++ b/src/subParsers/makemarkdown/image.js @@ -2,11 +2,13 @@ showdown.subParser('makeMarkdown.image', function (node) { 'use strict'; var txt = ''; - if (node.hasAttribute('src')) { + if (node.hasAttribute('src') && node.getAttribute('src') !== '') { txt += '![' + node.getAttribute('alt') + ']('; txt += '<' + node.getAttribute('src') + '>'; if (node.hasAttribute('width') && node.hasAttribute('height')) { - txt += ' =' + node.getAttribute('width') + 'x' + node.getAttribute('height'); + var width = node.getAttribute('width'); + var height = node.getAttribute('height'); + txt += ' =' + (width === 'auto' ? '*' : width) + 'x' + (height === 'auto' ? '*' : height); } if (node.hasAttribute('title')) {