fedimbed: parse more html to markdown

This commit is contained in:
Cynthia Foxwell 2023-10-21 17:12:31 -06:00
parent ab0f3756fe
commit 5a9a50a60f

View file

@ -461,6 +461,16 @@ async function processUrl(msg, url, spoiler = false) {
// TODO: convert certain HTML tags back to markdown // TODO: convert certain HTML tags back to markdown
content = content.replace(/<\/?\s*br\s*\/?>/g, "\n"); content = content.replace(/<\/?\s*br\s*\/?>/g, "\n");
content = content.replace(/<\/p><p>/g, "\n\n"); content = content.replace(/<\/p><p>/g, "\n\n");
content = content.replace(/<li>/g, "- ");
content = content.replace(/<\/li>/g, "\n");
content = content.replace(
/<a .*?href="([^"]+?)".*?>([^<]+?)<\/a>/g,
"[$2]($1)"
);
content = content.replace(/<\/?code>/g, "`");
content = content.replace(/<\/?em>/g, "*");
content = content.replace(/<\/?u>/g, "__");
content = content.replace(/<\/?s>/g, "~~");
content = content.replace(/(<([^>]+)>)/gi, ""); content = content.replace(/(<([^>]+)>)/gi, "");
content = parseHtmlEntities(content); content = parseHtmlEntities(content);