Replace <p> with <br /> and reeduce number of <br />

This commit is contained in:
Emmanuel 2024-12-20 21:54:40 +01:00
parent 0b01ca46c9
commit 69623677e9

View file

@ -375,7 +375,14 @@ async function cleanHtmlFragment(
return fragment === undefined
? undefined
: await prettier.format(
fragment.replaceAll("<<", "«").replaceAll(">>", "»"),
fragment
.replaceAll("<<", "«")
.replaceAll(">>", "»")
.replace(/<p>(.*?)<\/p>/gs, "$1<br />\n\n")
.replace(/\s*(<br\s*\/>\s*)+/gs, "<br />\n\n")
.replace(/^\s*(<br\s*\/>\s*)+/gs, "")
.replace(/\s*(<br\s*\/>\s*)+$/gs, "")
.trim(),
{
parser: "html",
},