remark-comment-config
Advanced tools
Comparing version 4.0.1 to 4.0.2
103
index.js
@@ -11,74 +11,59 @@ /** | ||
/* eslint-env commonjs */ | ||
/* Dependencies. */ | ||
var commentMarker = require('mdast-comment-marker'); | ||
/* | ||
* Dependencies. | ||
*/ | ||
/* Expose. */ | ||
module.exports = commentconfig; | ||
var commentMarker = require('mdast-comment-marker'); | ||
/** | ||
* Wrapper factory. | ||
* | ||
* @param {Function} original - Spied on function. | ||
* @return {Function} - Spy. | ||
* Modify `processor` to read configuration from comments. | ||
*/ | ||
function factory(original) { | ||
/** | ||
* Replacer for tokeniser or visitor. | ||
* | ||
* @param {Node|Function} node - Node, when visitor, | ||
* or `eat`. | ||
* @return {*} - Result of the spied on function. | ||
*/ | ||
function replacement(node) { | ||
var self = this; | ||
var result = original.apply(self, arguments); | ||
var marker = commentMarker(result && result.type ? result : node); | ||
function commentconfig(processor) { | ||
var Parser = processor.Parser; | ||
var Compiler = processor.Compiler; | ||
var block = Parser && Parser.prototype.blockTokenizers; | ||
var inline = Parser && Parser.prototype.inlineTokenizers; | ||
var compiler = Compiler && Compiler.prototype.visitors; | ||
if (marker && marker.name === 'remark') { | ||
try { | ||
self.setOptions(marker.parameters); | ||
} catch (exception) { | ||
self.file.fail(exception.message, marker.node); | ||
} | ||
} | ||
if (block && block.html) { | ||
block.html = factory(block.html); | ||
} | ||
return result; | ||
} | ||
if (inline && inline.html) { | ||
inline.html = factory(inline.html); | ||
} | ||
replacement.locator = original.locator; | ||
return replacement; | ||
if (compiler && compiler.html) { | ||
compiler.html = factory(compiler.html); | ||
} | ||
} | ||
/** | ||
* Modify remark to read configuration from comments. | ||
* | ||
* @param {Unified} processor - Instance. | ||
*/ | ||
function attacher(processor) { | ||
var Parser = processor.Parser; | ||
var Compiler = processor.Compiler; | ||
var block = Parser && Parser.prototype.blockTokenizers; | ||
var inline = Parser && Parser.prototype.inlineTokenizers; | ||
var compiler = Compiler && Compiler.prototype.visitors; | ||
/** Wrapper factory. */ | ||
function factory(original) { | ||
replacement.locator = original.locator; | ||
if (block) { | ||
block.html = factory(block.html); | ||
} | ||
return replacement; | ||
if (block) { | ||
inline.html = factory(inline.html); | ||
/** | ||
* Replacer for tokeniser or visitor. | ||
* | ||
* @param {Node|Function} node - Node, when visitor, | ||
* or `eat`. | ||
* @return {*} - Result of the spied on function. | ||
*/ | ||
function replacement(node) { | ||
var self = this; | ||
var result = original.apply(self, arguments); | ||
var marker = commentMarker(result && result.type ? result : node); | ||
if (marker && marker.name === 'remark') { | ||
try { | ||
self.setOptions(marker.parameters); | ||
} catch (err) { | ||
self.file.fail(err.message, marker.node); | ||
} | ||
} | ||
if (compiler && compiler.html) { | ||
compiler.html = factory(compiler.html); | ||
} | ||
return result; | ||
} | ||
} | ||
/* | ||
* Expose. | ||
*/ | ||
module.exports = attacher; |
{ | ||
"name": "remark-comment-config", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"description": "Configure remark with comments", | ||
@@ -13,9 +13,3 @@ "license": "MIT", | ||
], | ||
"dependencies": { | ||
"mdast-comment-marker": "^1.0.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wooorm/remark-comment-config.git" | ||
}, | ||
"repository": "https://github.com/wooorm/remark-comment-config", | ||
"bugs": "https://github.com/wooorm/remark-comment-config/issues", | ||
@@ -26,2 +20,8 @@ "author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
], | ||
"engines": { | ||
"node": ">=0.11.0" | ||
}, | ||
"dependencies": { | ||
"mdast-comment-marker": "^1.0.1" | ||
}, | ||
"files": [ | ||
@@ -32,28 +32,38 @@ "index.js" | ||
"browserify": "^13.0.0", | ||
"eslint": "^2.0.0", | ||
"esmangle": "^1.0.0", | ||
"istanbul": "^0.4.0", | ||
"jscs": "^3.0.0", | ||
"jscs-jsdoc": "^2.0.0", | ||
"remark": "^5.0.0", | ||
"remark-cli": "^1.0.0", | ||
"remark-github": "^5.0.0-alpga.1", | ||
"remark-html": "^4.0.0", | ||
"remark-lint": "^4.0.0", | ||
"remark-usage": "^4.0.0-alpha.1", | ||
"tape": "^4.0.0", | ||
"unified": "^4.1.2" | ||
"nyc": "^8.0.0", | ||
"remark": "^6.0.0", | ||
"remark-cli": "^2.0.0", | ||
"remark-html": "^5.0.0", | ||
"remark-preset-wooorm": "^1.0.0", | ||
"tape": "^4.4.0", | ||
"unified": "^5.0.0", | ||
"xo": "^0.16.0" | ||
}, | ||
"scripts": { | ||
"build-md": "remark . --quiet --frail", | ||
"build-bundle": "browserify --no-builtins index.js -s remarkCommentConfig > remark-comment-config.js", | ||
"build-bundle": "browserify index.js -s remarkCommentConfig > remark-comment-config.js", | ||
"build-mangle": "esmangle remark-comment-config.js > remark-comment-config.min.js", | ||
"build": "npm run build-md && npm run build-bundle && npm run build-mangle", | ||
"lint-api": "eslint .", | ||
"lint-style": "jscs --reporter inline .", | ||
"lint": "npm run lint-api && npm run lint-style", | ||
"test-api": "node test.js", | ||
"test-coverage": "istanbul cover test.js", | ||
"lint": "xo", | ||
"test-api": "node test", | ||
"test-coverage": "nyc --reporter lcov tape test.js", | ||
"test": "npm run build && npm run lint && npm run test-coverage" | ||
}, | ||
"nyc": { | ||
"check-coverage": true, | ||
"lines": 100, | ||
"functions": 100, | ||
"branches": 100 | ||
}, | ||
"xo": { | ||
"space": true, | ||
"ignores": [ | ||
"remark-comment-config.js" | ||
] | ||
}, | ||
"remarkConfig": { | ||
"output": true, | ||
"presets": "wooorm" | ||
} | ||
} |
@@ -13,5 +13,2 @@ # remark-comment-config [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] [![Chat][chat-badge]][chat] | ||
**remark-comment-config** is also available as an AMD, CommonJS, and | ||
globals module, [uncompressed and compressed][releases]. | ||
## Usage | ||
@@ -51,3 +48,3 @@ | ||
### `remark.use(commentConfig)` | ||
### `remark().use(commentConfig)` | ||
@@ -78,4 +75,2 @@ Parses comments, such as `<!--remark foo="bar" baz-->`, and passes the | ||
[releases]: https://github.com/wooorm/remark-comment-config/releases | ||
[license]: LICENSE | ||
@@ -82,0 +77,0 @@ |
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
10
6450
56
86
1
Updatedmdast-comment-marker@^1.0.1