Skip to content

Commit 136e5bd

Browse files
authored
Fix breakline
1 parent 66bb3fa commit 136e5bd

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

VIHTML.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,22 @@ function convertCustomHTML(config) {
5959
}
6060

6161
const parent = el.parentNode;
62-
62+
6363
if (voidElements.includes(newTagName)) {
64+
// Insert the void element
6465
parent.insertBefore(newEl, el);
65-
66+
67+
// Anchor: always insert after <br>, not after last inserted child
68+
let insertPoint = newEl.nextSibling;
69+
70+
// Move children **after the <br>**, preserving order
6671
while (el.firstChild) {
67-
parent.insertBefore(el.firstChild, newEl.nextSibling);
72+
parent.insertBefore(el.firstChild, insertPoint);
6873
}
69-
74+
7075
el.remove();
76+
}
77+
7178
} else {
7279
while (el.firstChild) {
7380
newEl.appendChild(el.firstChild);

0 commit comments

Comments
 (0)