FIX: Missing title attribute when quoting an image.

This commit is contained in:
Guo Xiang Tan 2019-06-06 16:45:12 +08:00
parent 2265c5102f
commit 782da448a2
2 changed files with 5 additions and 1 deletions

View File

@ -241,6 +241,7 @@ export class Tag {
let alt = attr.alt || pAttr.alt || "";
const width = attr.width || pAttr.width;
const height = attr.height || pAttr.height;
const title = attr.title;
if (width && height) {
const pipe = this.element.parentNames.includes("table")
@ -249,7 +250,7 @@ export class Tag {
alt = `${alt}${pipe}${width}x${height}`;
}
return "![" + alt + "](" + src + ")";
return `![${alt}](${src}${title ? ` "${title}"` : ""})`;
}
return "";

View File

@ -166,6 +166,9 @@ QUnit.test("converts img tag", assert => {
let html = `<img src="${url}" width="100" height="50">`;
assert.equal(toMarkdown(html), `![|100x50](${url})`);
html = `<img src="${url}" width="100" height="50" title="some title">`;
assert.equal(toMarkdown(html), `![|100x50](${url} "some title")`);
html = `<div><span><img src="${url}" alt="description" width="50" height="100" /></span></div>`;
assert.equal(toMarkdown(html), `![description|50x100](${url})`);