Skip to content

Commit 93e3c97

Browse files
rlszQingWei-Li
authored andcommitted
fix bug
fix bug: char '<' leads to error
1 parent 05ab10f commit 93e3c97

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

example/src/markdown.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Vue.config.debug = true
4242
}
4343
</style>
4444
<script>
45+
let a=1<2;
4546
console.log("***This script tag is successfully extracted and excuted.***")
4647
module.exports = {
4748
components: {
@@ -63,7 +64,7 @@ Vue.config.debug = true
6364
}
6465
}
6566
</script>
66-
67+
jjjjjjjjjjjjjjjjjjjjjj
6768
<template>
6869
<div></div>
6970
</template>

lib/markdown-compiler.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,17 @@ module.exports = function (source) {
8282

8383
//add ruler:extract script and style tags from html token content
8484
parser.core.ruler.push('extract_script_or_style', function replace(state) {
85-
let tag_reg=new RegExp("<(script|style)[^<]*<\/\\1>",'g');
85+
let tag_reg=new RegExp("<(script|style)(?:[^<]|<)+<\/\\1>",'g');
8686
let newTokens=[];
8787
state.tokens.filter(token=>token.type=='fence' && token.info=='html').forEach(token=>{
8888
let tokens=(token.content.match(tag_reg)||[]).map(content=>{
8989
let t=new Token('html_block', '', 0);
9090
t.content=content;
9191
return t;
9292
});
93-
if(tokens.length>0) newTokens.push.apply(newTokens, tokens);
93+
if(tokens.length>0){
94+
newTokens.push.apply(newTokens, tokens);
95+
}
9496
})
9597
state.tokens.push.apply(state.tokens, newTokens);
9698
});

0 commit comments

Comments
 (0)