mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-23 09:45:46 +03:00
Fix infinite loop bug!!
This commit is contained in:
parent
7aba448f42
commit
82c8247ac8
1 changed files with 5 additions and 3 deletions
|
@ -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) => {
|
||||
|
|
Loading…
Reference in a new issue