This commit is contained in:
2026-01-17 02:03:17 +01:00
parent a39a498b9f
commit 1910b6d296

View File

@@ -31,6 +31,13 @@
const unwrap = (el, addBreak) => {
const frag = document.createDocumentFragment();
if (addBreak) {
const prev = el.previousSibling;
const needsLeadBreak = !!(prev && (prev.nodeType === 3 ? prev.textContent.trim() : (prev.tagName && prev.tagName !== 'BR')));
if (needsLeadBreak) {
frag.appendChild(document.createElement('br'));
}
}
while (el.firstChild) {
frag.appendChild(el.firstChild);
}
@@ -60,6 +67,7 @@
let html = wrapper.innerHTML
.replace(/<br\s*\/?>/gi, '<br>')
.replace(/(<br>)+$/g, '')
.trim();
if (!html) {
const text = String(fallbackText || wrapper.textContent || '').trim();