fedimbed: less smart anchor tag regex since nested tags wont break anything

This commit is contained in:
Cynthia Foxwell 2023-12-28 13:43:21 -07:00
parent 79cf9b9be7
commit 92d70621ab

View file

@ -512,16 +512,13 @@ async function processUrl(msg, url, spoiler = false) {
content = content ?? ""; content = content ?? "";
cw = cw ?? ""; cw = cw ?? "";
// TODO: convert certain HTML tags back to markdown // FIXME: stop being lazy and use an html parser
content = content.replace(/<a .*?href="([^"]+?)".*?>(.+?)<\/a>/g, "[$2]($1)");
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(/<ol>/g, "\n"); content = content.replace(/<ol>/g, "\n");
content = content.replace(/<li>/g, "- "); content = content.replace(/<li>/g, "- ");
content = content.replace(/<\/li>/g, "\n"); content = content.replace(/<\/li>/g, "\n");
content = content.replace(
/<a .*?href="([^"]+?)".*?>([^<]+?)<\/a>/g,
"[$2]($1)"
);
content = content.replace(/<\/?code>/g, "`"); content = content.replace(/<\/?code>/g, "`");
content = content.replace(/<\/?em>/g, "*"); content = content.replace(/<\/?em>/g, "*");
content = content.replace(/<\/?u>/g, "__"); content = content.replace(/<\/?u>/g, "__");