Skip to content

Build your personal knowledge base with Trilium Notes

fix: improve <pre> tag regex handling when formatting HTML strings

SiriusXTfa2188f087ef
diff --git a/apps/client/src/services/utils.ts b/apps/client/src/services/utils.ts
index bf3894474b..a8f4f567fe 100644
--- a/apps/client/src/services/utils.ts
+++ b/apps/client/src/services/utils.ts
@@ -304,7 +304,7 @@ function formatHtml(html: string) {
let pre: { indent: string; tag: string }[] = [];
html = html
- .replace(new RegExp("<pre>((.|\\t|\\n|\\r)+)?</pre>"), function (x) {
+ .replace(new RegExp("<pre>([\\s\\S]+?)?</pre>"), function (x) {
pre.push({ indent: "", tag: x });
return "<--TEMPPRE" + i++ + "/-->";
})