fedimbed: would help to actually add the changes in
This commit is contained in:
parent
e14cf5f9d9
commit
a5ee7d3f44
1 changed files with 16 additions and 13 deletions
|
@ -631,24 +631,27 @@ async function processUrl(msg, url, spoiler = false) {
|
||||||
cw = cw ?? "";
|
cw = cw ?? "";
|
||||||
|
|
||||||
// FIXME: stop being lazy and use an html parser
|
// FIXME: stop being lazy and use an html parser
|
||||||
content = content.replace(/<a .*?href="([^"]+?)".*?>(.+?)<\/a>/g, "[$2]($1)");
|
|
||||||
content = content.replace(
|
content = content.replace(
|
||||||
/<img .*?src="([^"]+?)".*?(alt|title)="([^"]+?)".*?\/>/g,
|
/<a .*?href="([^"]+?)".*?>(.+?)<\/a>/gi,
|
||||||
|
"[$2]($1)"
|
||||||
|
);
|
||||||
|
content = content.replace(
|
||||||
|
/<img .*?src="([^"]+?)".*?(alt|title)="([^"]+?)".*?\/>/gi,
|
||||||
"[$3]($1)"
|
"[$3]($1)"
|
||||||
);
|
);
|
||||||
content = content.replace(/<\/?\s*br\s*\/?>/g, "\n");
|
content = content.replace(/<\/?\s*br\s*\/?>/gi, "\n");
|
||||||
content = content.replace(
|
content = content.replace(
|
||||||
/<blockquote.*?>(.*?)<\/blockquote>/,
|
/<blockquote.*?>((.|\n)*?)<\/blockquote>/gi,
|
||||||
(_, c) => "> " + c.split("\n").join("\n> ")
|
(_, quote) => "> " + quote.split("\n").join("\n> ")
|
||||||
);
|
);
|
||||||
content = content.replace(/<\/p><p>/g, "\n\n");
|
content = content.replace(/<\/p><p>/gi, "\n\n");
|
||||||
content = content.replace(/<ol>/g, "\n");
|
content = content.replace(/<ol>/gi, "\n");
|
||||||
content = content.replace(/<li>/g, "- ");
|
content = content.replace(/<li>/gi, "- ");
|
||||||
content = content.replace(/<\/li>/g, "\n");
|
content = content.replace(/<\/li>/gi, "\n");
|
||||||
content = content.replace(/<\/?code>/g, "`");
|
content = content.replace(/<\/?code>/gi, "`");
|
||||||
content = content.replace(/<\/?em>/g, "*");
|
content = content.replace(/<\/?em>/gi, "*");
|
||||||
content = content.replace(/<\/?u>/g, "__");
|
content = content.replace(/<\/?u>/gi, "__");
|
||||||
content = content.replace(/<\/?s>/g, "~~");
|
content = content.replace(/<\/?s>/gi, "~~");
|
||||||
content = content.replace(/(<([^>]+)>)/gi, "");
|
content = content.replace(/(<([^>]+)>)/gi, "");
|
||||||
content = parseHtmlEntities(content);
|
content = parseHtmlEntities(content);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue