feat: supports image titles as comment (#291)

close #290
This commit is contained in:
YangFong 2024-04-28 09:43:39 +08:00 committed by GitHub
parent e98a5b5103
commit 97f42c9d0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -168,14 +168,17 @@ class WxRenderer {
return `<ol ${getStyles("ol")}>${text}</ol>`;
};
renderer.image = (href, title, text) => {
let subText = "";
if (text) {
subText = `<figcaption ${getStyles(
"figcaption"
)}>${text}</figcaption>`;
const createSubText = (s) => {
if (!s) {
return "";
}
let figureStyles = getStyles("figure");
let imgStyles = getStyles("image");
return `<figcaption ${getStyles("figcaption")}>${s}</figcaption>`;
};
const subText = createSubText(title || text);
const figureStyles = getStyles("figure");
const imgStyles = getStyles("image");
return `<figure ${figureStyles}><img ${imgStyles} src="${href}" title="${title}" alt="${text}"/>${subText}</figure>`;
};
renderer.link = (href, title, text) => {