fix: list item tag (#139)

This commit is contained in:
Yang Libin 2022-03-16 09:52:34 +08:00 committed by GitHub
parent c92c454cea
commit 7d1a8d5644
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -136,22 +136,22 @@ class WxRenderer {
renderer.codespan = (text, lang) => renderer.codespan = (text, lang) =>
`<code ${getStyles("codespan")}>${text}</code>`; `<code ${getStyles("codespan")}>${text}</code>`;
renderer.listitem = (text) => renderer.listitem = (text) =>
`<span ${getStyles( `<li ${getStyles(
"listitem" "listitem"
)}><span style="margin-right: 10px;"><%s/></span>${text}</span>`; )}><span><%s/></span>${text}</li>`;
renderer.list = (text, ordered, start) => { renderer.list = (text, ordered, start) => {
text = text.replace(/<\/*p.*?>/g, ""); text = text.replace(/<\/*p.*?>/g, "");
let segments = text.split(`<%s/>`); let segments = text.split(`<%s/>`);
if (!ordered) { if (!ordered) {
text = segments.join("• "); text = segments.join("• ");
return `<p ${getStyles("ul")}>${text}</p>`; return `<ul ${getStyles("ul")}>${text}</ul>`;
} }
text = segments[0]; text = segments[0];
for (let i = 1; i < segments.length; i++) { for (let i = 1; i < segments.length; i++) {
text = text + i + ". " + segments[i]; text = text + i + ". " + segments[i];
} }
return `<p ${getStyles("ol")}>${text}</p>`; return `<ol ${getStyles("ol")}>${text}</ol>`;
}; };
renderer.image = (href, title, text) => { renderer.image = (href, title, text) => {
let subText = ""; let subText = "";