micromark-extension-gfm-tagfilter
Advanced tools
Comparing version 0.1.0 to 0.2.0
23
html.js
@@ -18,10 +18,7 @@ exports.enter = { | ||
var insideHtmlFlow | ||
var insideHtmlText | ||
function enterHtmlFlowWithTagFilter() { | ||
insideHtmlFlow = true | ||
this.lineEndingIfNeeded() | ||
this.setData('insideHtmlFlow', true) | ||
if (this.options.allowDangerousHtml) { | ||
this.setIgnoreEncode(true) | ||
this.setData('ignoreEncode', true) | ||
} | ||
@@ -31,5 +28,5 @@ } | ||
function enterHtmlTextWithTagFilter() { | ||
insideHtmlText = true | ||
this.setData('insideHtmlText', true) | ||
if (this.options.allowDangerousHtml) { | ||
this.setIgnoreEncode(true) | ||
this.setData('ignoreEncode', true) | ||
} | ||
@@ -39,5 +36,5 @@ } | ||
function exitHtml() { | ||
this.setIgnoreEncode() | ||
insideHtmlFlow = undefined | ||
insideHtmlText = undefined | ||
this.setData('ignoreEncode') | ||
this.setData('insideHtmlFlow') | ||
this.setData('insideHtmlText') | ||
} | ||
@@ -47,3 +44,7 @@ | ||
var value = this.sliceSerialize(token) | ||
var filter = insideHtmlFlow ? reFlow : insideHtmlText ? reText : undefined | ||
var filter = this.getData('insideHtmlFlow') | ||
? reFlow | ||
: this.getData('insideHtmlText') | ||
? reText | ||
: undefined | ||
@@ -50,0 +51,0 @@ if (filter && this.options.allowDangerousHtml) { |
{ | ||
"name": "micromark-extension-gfm-tagfilter", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "micromark extension to support GFM tagfilter", | ||
@@ -34,3 +34,3 @@ "license": "MIT", | ||
"devDependencies": { | ||
"micromark": "~2.4.0", | ||
"micromark": "~2.5.0", | ||
"nyc": "^15.0.0", | ||
@@ -37,0 +37,0 @@ "prettier": "^2.0.0", |
@@ -11,3 +11,6 @@ # micromark-extension-gfm-tagfilter | ||
**[micromark][]** extension to support GitHub flavored markdown tagfilter. | ||
**[micromark][]** extension to support GitHub flavored markdown [tag filter][]. | ||
This syntax extension matches the GFM spec and github.com. | ||
The [tag filter][] is a rather naïve attempt at XSS protection. | ||
It’s much better to use a proper HTML sanitizing algorithm. | ||
@@ -17,9 +20,2 @@ This package provides the low-level modules for integrating with the micromark | ||
The [tag filter][] defined by GFM is a rather naïve attempt at XSS protection. | ||
It’s much better to use a proper HTML sanitizing algorithm. | ||
This syntax extension matches the GitHub parser. | ||
You probably shouldn’t use this package directly, but instead use | ||
[`mdast-util-gfm-tagfilter`][mdast-util-gfm-tagfilter] with **[mdast][]**. | ||
## Install | ||
@@ -40,3 +36,3 @@ | ||
Support a [tag filter][] (protection against script, plaintext, etc). | ||
The export is an extensions for the default HTML compiler (to escape certain | ||
The export is an extension for the default HTML compiler (to escape certain | ||
tag names; can be passed in `htmlExtensions`). | ||
@@ -50,4 +46,2 @@ | ||
— the smallest commonmark-compliant markdown parser that exists | ||
* [`syntax-tree/mdast-util-gfm-tagfilter`][mdast-util-gfm-tagfilter] | ||
— mdast utility to support the tagfilter | ||
* [`syntax-tree/mdast-util-from-markdown`][from-markdown] | ||
@@ -120,6 +114,2 @@ — mdast parser using `micromark` to create mdast from markdown | ||
[mdast]: https://github.com/syntax-tree/mdast | ||
[mdast-util-gfm-tagfilter]: https://github.com/syntax-tree/mdast-util-gfm-tagfilter | ||
[tag filter]: https://github.github.com/gfm/#disallowed-raw-html-extension- |
46
7653
111