remark-retext
Advanced tools
Comparing version 2.0.0 to 3.0.0
86
index.js
@@ -1,71 +0,37 @@ | ||
/** | ||
* @author Titus Wormer | ||
* @copyright 2015 Titus Wormer | ||
* @license MIT | ||
* @module remark:retext | ||
* @fileoverview Bridge / mutate from remark to retext. | ||
*/ | ||
'use strict'; | ||
/* eslint-env commonjs */ | ||
/* Dependencies */ | ||
var mdast2nlcst = require('mdast-util-to-nlcst'); | ||
/** | ||
* Mutate-mode. Further transformers run on the NLCST tree. | ||
* | ||
* @param {Function} parser - NLCST Parser. | ||
* @return {NLCSTNode} - Tree. | ||
*/ | ||
function mutate(parser) { | ||
/** | ||
* Transformer. | ||
* | ||
* @param {MDASTNode} node - Tree. | ||
* @param {VFile} file - Virtual file. | ||
* @return {NLCSTNode} - Tree. | ||
*/ | ||
return function (node, file) { | ||
return mdast2nlcst(node, file, parser); | ||
} | ||
} | ||
module.exports = remark2retext; | ||
/** | ||
* Bridge-mode. Runs the destination with the new NLCST | ||
* tree. | ||
* | ||
* @param {Unified} destination - Destination processor. | ||
* @return {Function} - Transformer. | ||
*/ | ||
function bridge(destination) { | ||
return function (node, file, next) { | ||
var tree = mdast2nlcst(node, file, destination.Parser); | ||
destination.run(tree, file, function (err) { | ||
next(err); | ||
}); | ||
}; | ||
} | ||
/** | ||
* Attacher. | ||
/* Attacher. | ||
* If a destination processor is given, runs the destination | ||
* with the new NLCST tree (bridge-mode). | ||
* If a parser is given, returns the NLCST tree: further | ||
* plug-ins run on that tree (mutate-mode). | ||
* | ||
* @param {Unified} origin - Origin processor. | ||
* @param {Unified|Function} destination - Destination, | ||
* processor or NLCST parser constructor. | ||
* @return {Function} - Transformer. | ||
*/ | ||
function attacher(origin, destination) { | ||
var fn = destination && destination.run ? bridge : mutate; | ||
* plug-ins run on that tree (mutate-mode). */ | ||
function remark2retext(destination) { | ||
var fn = destination && destination.run ? bridge : mutate; | ||
return fn(destination); | ||
} | ||
return fn(destination); | ||
/* Mutate-mode. Further transformers run on the NLCST tree. */ | ||
function mutate(parser) { | ||
return transformer; | ||
function transformer(node, file) { | ||
return mdast2nlcst(node, file, parser); | ||
} | ||
} | ||
/* Expose. */ | ||
module.exports = attacher; | ||
/* Bridge-mode. Runs the destination with the new NLCST | ||
* tree. */ | ||
function bridge(destination) { | ||
return transformer; | ||
function transformer(node, file, next) { | ||
var Parser = destination.freeze().Parser; | ||
var tree = mdast2nlcst(node, file, Parser); | ||
destination.run(tree, file, function (err) { | ||
next(err); | ||
}); | ||
} | ||
} |
{ | ||
"name": "remark-retext", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "retext support for remark", | ||
@@ -15,6 +15,3 @@ "license": "MIT", | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wooorm/remark-retext.git" | ||
}, | ||
"repository": "https://github.com/wooorm/remark-retext", | ||
"bugs": "https://github.com/wooorm/remark-retext/issues", | ||
@@ -29,21 +26,14 @@ "author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
"devDependencies": { | ||
"browserify": "^13.0.1", | ||
"eslint": "^2.0.0", | ||
"browserify": "^14.0.0", | ||
"esmangle": "^1.0.1", | ||
"istanbul": "^0.4.0", | ||
"jscs": "^3.0.0", | ||
"jscs-jsdoc": "^2.0.0", | ||
"remark-cli": "^1.0.0", | ||
"remark-comment-config": "^4.0.0", | ||
"remark-github": "^5.0.0", | ||
"remark-lint": "^4.0.0", | ||
"remark-parse": "^1.0.0", | ||
"remark-stringify": "^1.0.0", | ||
"remark-validate-links": "^4.0.0", | ||
"retext-english": "^2.0.0", | ||
"retext-equality": "^2.3.0", | ||
"retext-stringify": "^1.0.0", | ||
"nyc": "^10.0.0", | ||
"remark-cli": "^2.0.0", | ||
"remark-parse": "^3.0.0", | ||
"remark-preset-wooorm": "^1.0.0", | ||
"remark-stringify": "^3.0.0", | ||
"retext-english": "^3.0.0", | ||
"retext-stringify": "^2.0.0", | ||
"tape": "^4.0.0", | ||
"unified": "^4.1.2", | ||
"vfile-reporter": "^1.5.0" | ||
"unified": "^6.0.0", | ||
"xo": "^0.17.1" | ||
}, | ||
@@ -55,9 +45,23 @@ "scripts": { | ||
"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", | ||
"lint": "xo", | ||
"test-api": "node test.js", | ||
"test-coverage": "istanbul cover test.js", | ||
"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-retext.js" | ||
] | ||
}, | ||
"remarkConfig": { | ||
"output": true, | ||
"presets": "wooorm" | ||
} | ||
} |
# remark-retext [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] | ||
<!--lint disable heading-increment list-item-spacing--> | ||
Bridge / mutate from [**remark**][remark] to [**retext**][retext]. | ||
@@ -9,3 +7,3 @@ | ||
[npm][npm-install]: | ||
[npm][]: | ||
@@ -86,3 +84,3 @@ ```bash | ||
[npm-install]: https://docs.npmjs.com/cli/install | ||
[npm]: https://docs.npmjs.com/cli/install | ||
@@ -89,0 +87,0 @@ [license]: LICENSE |
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
12
6632
4
31
106
1