Improve search

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2022-08-22 12:12:09 +02:00
parent 444e0d6a0c
commit baac00f678
36 changed files with 1343 additions and 1013 deletions

View File

@@ -2,6 +2,11 @@ export function nl2br(text: string): string {
return text.replace(/(?:\r\n|\r|\n)/g, "<br>");
}
export function flattenHTMLParagraphs(html: string): string {
return html.replace("</p><p>", "<br />").replace(/<?\/p>/g, "");
export function htmlToText(html: string) {
const template = document.createElement("template");
const trimmedHTML = html.trim();
template.innerHTML = trimmedHTML;
const text = template.content.textContent;
template.remove();
return text;
}