Fix infinite loop bug!!

pull/54/head
Lim Chee Aun 2023-02-17 01:54:19 +08:00
rodzic 7aba448f42
commit 82c8247ac8
1 zmienionych plików z 5 dodań i 3 usunięć

Wyświetl plik

@ -51,8 +51,9 @@ function enhanceContent(content, opts = {}) {
codeBlocks.forEach((block) => {
const nextParagraphs = [block];
let hasCodeBlock = false;
do {
const next = block.nextElementSibling;
let currentBlock = block;
while (currentBlock.nextElementSibling) {
const next = currentBlock.nextElementSibling;
if (next && next.tagName === 'P') {
if (/```$/g.test(next.innerText)) {
nextParagraphs.push(next);
@ -64,7 +65,8 @@ function enhanceContent(content, opts = {}) {
} else {
break;
}
} while (true);
currentBlock = next;
}
if (hasCodeBlock) {
const pre = document.createElement('pre');
nextParagraphs.forEach((p) => {