Skip to content

Commit

Permalink
feat: supports image titles as comment (doocs#291)
Browse files Browse the repository at this point in the history
close doocs#290
  • Loading branch information
YangFong authored Apr 28, 2024
1 parent e98a5b5 commit 97f42c9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/assets/scripts/renderers/wx-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>`;
}
let figureStyles = getStyles("figure");
let imgStyles = getStyles("image");
const createSubText = (s) => {
if (!s) {
return "";
}

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) => {
Expand Down

0 comments on commit 97f42c9

Please sign in to comment.