rehype-ignore
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -14,10 +14,15 @@ import { visit } from 'unist-util-visit'; | ||
node.children = node.children.filter((item) => { | ||
if (item.type === 'comment' && item.value.trim() === openDelimiter) { | ||
start = true; | ||
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; | ||
} | ||
} | ||
if (item.type === 'comment' && item.value.trim() === closeDelimiter) { | ||
start = false; | ||
return false; | ||
} | ||
return !start; | ||
@@ -24,0 +29,0 @@ }); |
{ | ||
"name": "rehype-ignore", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Ignore content display via HTML comments, Shown in GitHub readme, excluded in HTML.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://jaywcjlove.github.io/rehype-ignore", |
@@ -9,2 +9,3 @@ rehype-ignore | ||
[![Coverage Status](https://jaywcjlove.github.io/rehype-ignore/badges.svg)](https://jaywcjlove.github.io/rehype-ignore/lcov-report/) | ||
[![Repo Dependents](https://badgen.net/github/dependents-repo/jaywcjlove/rehype-ignore)](https://github.com/jaywcjlove/rehype-ignore/network/dependents) | ||
@@ -127,2 +128,3 @@ Ignore content display via HTML comments, Shown in GitHub readme, excluded in HTML. | ||
- [`rehype-attr`](https://github.com/jaywcjlove/rehype-attr) New syntax to add attributes to Markdown. | ||
- [`rehype-ignore`](https://github.com/jaywcjlove/rehype-ignore) Ignore content display via HTML comments, Shown in GitHub readme, excluded in HTML. | ||
- [`rehypejs`](https://github.com/rehypejs/rehype) HTML processor powered by plugins part of the @unifiedjs collective | ||
@@ -129,0 +131,0 @@ - [`remark-parse`](https://www.npmjs.com/package/remark-parse) remark plugin to parse Markdown |
@@ -74,2 +74,15 @@ import { unified } from 'unified'; | ||
it('rehypeIgnore test case openDelimiter/closeDelimiter', async () => { | ||
const html = `<!--idoc:start--><h1>header</h1><!--idoc:end-->`; | ||
const htmlStr = rehype() | ||
.data('settings', { fragment: true }) | ||
.use(rehypeIgnore, { | ||
openDelimiter: 'idoc:start', | ||
closeDelimiter: 'idoc:end', | ||
}) | ||
.use(stringify) | ||
.processSync(html) | ||
.toString() | ||
expect(htmlStr).toEqual(''); | ||
}); | ||
@@ -76,0 +89,0 @@ it('rehypeIgnore test case', async () => { |
@@ -28,10 +28,15 @@ import { Plugin } from 'unified'; | ||
node.children = node.children.filter((item) => { | ||
if (item.type === 'comment' && item.value.trim() === openDelimiter) { | ||
start = true; | ||
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; | ||
} | ||
} | ||
if (item.type === 'comment' && item.value.trim() === closeDelimiter) { | ||
start = false; | ||
return false | ||
} | ||
@@ -38,0 +43,0 @@ return !start; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14656
194
147