Skip to content

Commit 3d77fcd

Browse files
miguelcobainsamselikoff
authored andcommitted
test balance without escaped code
1 parent e7087e1 commit 3d77fcd

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/utils/compile-markdown.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ function compactParagraphs(tokens) {
4646
last.text = `${last.text} ${token.text}`;
4747
}
4848

49-
balance += count(/(?<!`.*){{#/g, token.text);
50-
balance += count(/(?<!`.*)<[A-Z]/g, token.text);
51-
balance -= count(/{{\/.*}}(?!.*`)/g, token.text);
52-
balance -= count(/<\/[A-Z][a-z]+>(?!.*`)/g, token.text);
49+
let tokenText = token.text || '';
50+
let textWithoutCode = tokenText.replace(/`[\s\S]*?`/g, '');
51+
52+
balance += count(/{{#/g, textWithoutCode);
53+
balance += count(/<[A-Z]/g, textWithoutCode);
54+
balance -= count(/{{\//g, textWithoutCode);
55+
balance -= count(/<\/[A-Z]/g, textWithoutCode);
5356
}
5457

5558
return compacted;

0 commit comments

Comments
 (0)