-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
37 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,31 +7,22 @@ var sanitize = require('hast-util-sanitize'); | |
|
||
module.exports = plugin; | ||
|
||
function plugin(processor, options) { | ||
function plugin(options) { | ||
var settings = options || {}; | ||
var clean = settings.sanitize; | ||
var schema = clean && typeof clean === 'object' ? clean : null; | ||
var handlers = settings.handlers || {}; | ||
|
||
Compiler.prototype.compile = compile; | ||
this.Compiler = compiler; | ||
|
||
processor.Compiler = Compiler; | ||
|
||
function Compiler(file) { | ||
/* istanbul ignore if - [email protected] */ | ||
if (file.extension) { | ||
file.move({extension: 'html'}); | ||
} | ||
function compiler(node, file) { | ||
var root = node && node.type && node.type === 'root'; | ||
var hast = toHAST(node, {allowDangerousHTML: !clean, handlers: handlers}); | ||
var result; | ||
|
||
if (file.extname) { | ||
file.extname = '.html'; | ||
} | ||
} | ||
|
||
function compile(node) { | ||
var root = node && node.type && node.type === 'root'; | ||
var hast = toHAST(node, {allowDangerousHTML: !clean, handlers: handlers}); | ||
var result; | ||
|
||
if (clean) { | ||
hast = sanitize(hast, schema); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,16 +10,7 @@ | |
"compile", | ||
"remark" | ||
], | ||
"dependencies": { | ||
"hast-util-sanitize": "^1.0.0", | ||
"hast-util-to-html": "^3.0.0", | ||
"mdast-util-to-hast": "^2.1.1", | ||
"xtend": "^4.0.1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wooorm/remark-html.git" | ||
}, | ||
"repository": "https://github.com/wooorm/remark-html", | ||
"bugs": "https://github.com/wooorm/remark-html/issues", | ||
"author": "Titus Wormer <[email protected]> (http://wooorm.com)", | ||
"contributors": [ | ||
|
@@ -28,23 +19,29 @@ | |
"files": [ | ||
"index.js" | ||
], | ||
"dependencies": { | ||
"hast-util-sanitize": "^1.0.0", | ||
"hast-util-to-html": "^3.0.0", | ||
"mdast-util-to-hast": "^2.1.1", | ||
"xtend": "^4.0.1" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^14.0.0", | ||
"commonmark.json": "^0.27.0", | ||
"esmangle": "^1.0.0", | ||
"is-hidden": "^1.0.1", | ||
"nyc": "^10.0.0", | ||
"remark": "^6.0.0", | ||
"remark": "^7.0.0", | ||
"remark-cli": "^2.0.0", | ||
"remark-github": "^6.0.1", | ||
"remark-github": "^7.0.0", | ||
"remark-preset-wooorm": "^1.0.0", | ||
"remark-toc": "^3.1.0", | ||
"remark-toc": "^4.0.0", | ||
"tape": "^4.0.0", | ||
"to-vfile": "^2.0.0", | ||
"xo": "^0.17.1" | ||
}, | ||
"scripts": { | ||
"build-md": "remark *.md doc/*.md --quiet --frail", | ||
"build-md": "# remark *.md doc/*.md --quiet --frail", | ||
"build-bundle": "browserify index.js --bare -s remarkHTML > remark-html.js", | ||
"build-mangle": "esmangle remark-html.js > remark-html.min.js", | ||
"build": "npm run build-md && npm run build-bundle && npm run build-mangle", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters