Skip to content

Commit

Permalink
fix: fix the type raw also works.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Oct 23, 2022
1 parent 1ed00cf commit 7152e2d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@ const rehypeIgnore: Plugin<[RehypeIgnoreOptions?], Root> = (options = {}) => {
// }
let start = false;
node.children = node.children.filter((item) => {
if (item.type === 'comment' && item.value.trim() === openDelimiter) {
start = true;
return false
}
if (item.type === 'comment' && item.value.trim() === closeDelimiter) {
start = false;
return false
if (item.type === 'raw' || item.type === 'comment') {
let str = item.value?.trim();
str = str.replace(/^<!--(.*?)-->/, '$1')
console.log('str::', item.type, str)
if (str === openDelimiter) {
start = true;
return false;
}
if (str === closeDelimiter) {
start = false;
return false;
}
}

return !start;
Expand Down

0 comments on commit 7152e2d

Please sign in to comment.