From 97f42c9d0d04022ba7eba2da08ba53c5d5cb65ba Mon Sep 17 00:00:00 2001 From: YangFong Date: Sun, 28 Apr 2024 09:43:39 +0800 Subject: [PATCH] feat: supports image titles as comment (#291) close #290 --- src/assets/scripts/renderers/wx-renderer.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/assets/scripts/renderers/wx-renderer.js b/src/assets/scripts/renderers/wx-renderer.js index 3e954b4..8fe8c42 100644 --- a/src/assets/scripts/renderers/wx-renderer.js +++ b/src/assets/scripts/renderers/wx-renderer.js @@ -168,14 +168,17 @@ class WxRenderer { return `
    ${text}
`; }; renderer.image = (href, title, text) => { - let subText = ""; - if (text) { - subText = `
${text}
`; - } - let figureStyles = getStyles("figure"); - let imgStyles = getStyles("image"); + const createSubText = (s) => { + if (!s) { + return ""; + } + + return `
${s}
`; + }; + + const subText = createSubText(title || text); + const figureStyles = getStyles("figure"); + const imgStyles = getStyles("image"); return `
${text}${subText}
`; }; renderer.link = (href, title, text) => {