@threadlabs/looma 0.16.4 → 0.16.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8631,6 +8631,13 @@ function parseHtmlSlice(schema, value) {
|
|
|
8631
8631
|
const parsed = new globalThis.DOMParser().parseFromString(value, "text/html");
|
|
8632
8632
|
if (parsed.body.style.display === "none") return Slice.empty;
|
|
8633
8633
|
for (const element of parsed.body.querySelectorAll("[style]")) if (element.style.display === "none") element.remove();
|
|
8634
|
+
for (const wrapper of parsed.body.querySelectorAll("div")) for (const child of wrapper.children) {
|
|
8635
|
+
const next = child.nextSibling;
|
|
8636
|
+
if (child.localName !== "span" || next?.nodeType !== 1 || next.localName !== "span") continue;
|
|
8637
|
+
if (!child.textContent?.trim() || !next.textContent?.trim()) continue;
|
|
8638
|
+
if (/\s$/.test(child.textContent) || /^\s/.test(next.textContent)) continue;
|
|
8639
|
+
wrapper.insertBefore(parsed.createTextNode(" "), next);
|
|
8640
|
+
}
|
|
8634
8641
|
const container = document.createElement("div");
|
|
8635
8642
|
container.append(purify.sanitize(parsed.body.innerHTML, {
|
|
8636
8643
|
USE_PROFILES: { html: true },
|