fix(makemarkdown.image): fix bug width|height = auto

`<img src="a" width="auto" height="auto" />` transforms into `![null](<a> =autoxauto)`.
After fix, the output becomes `![null](<a> =*x*)`

Closes #622
This commit is contained in:
ggboy-shakalaka 2022-04-26 01:43:58 +08:00 committed by GitHub
parent 9e5d0f3f11
commit 440170aadc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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')) {