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) => {
|
codeBlocks.forEach((block) => {
|
||||||
const nextParagraphs = [block];
|
const nextParagraphs = [block];
|
||||||
let hasCodeBlock = false;
|
let hasCodeBlock = false;
|
||||||
do {
|
let currentBlock = block;
|
||||||
const next = block.nextElementSibling;
|
while (currentBlock.nextElementSibling) {
|
||||||
|
const next = currentBlock.nextElementSibling;
|
||||||
if (next && next.tagName === 'P') {
|
if (next && next.tagName === 'P') {
|
||||||
if (/```$/g.test(next.innerText)) {
|
if (/```$/g.test(next.innerText)) {
|
||||||
nextParagraphs.push(next);
|
nextParagraphs.push(next);
|
||||||
|
@ -64,7 +65,8 @@ function enhanceContent(content, opts = {}) {
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (true);
|
currentBlock = next;
|
||||||
|
}
|
||||||
if (hasCodeBlock) {
|
if (hasCodeBlock) {
|
||||||
const pre = document.createElement('pre');
|
const pre = document.createElement('pre');
|
||||||
nextParagraphs.forEach((p) => {
|
nextParagraphs.forEach((p) => {
|
||||||
|
|
Loading…
Reference in a new issue