Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remark-retext

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-retext - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

5

history.md

@@ -5,2 +5,7 @@ <!--remark setext-->

2.0.0 / 2016-06-22
==================
* Add support for mutating; refactor module ([`3f5e85a`](https://github.com/wooorm/remark-retext/commit/3f5e85a))
1.1.0 / 2016-01-12

@@ -7,0 +12,0 @@ ==================

71

index.js
/**
* @author Titus Wormer
* @copyright 2016 Titus Wormer
* @copyright 2015 Titus Wormer
* @license MIT
* @module remark:retext
* @fileoverview retext support for remark.
* @fileoverview Bridge / mutate from remark to retext.
*/

@@ -13,27 +13,60 @@

/*
* Dependencies.
*/
var bridge = require('unified-bridge');
/* Dependencies */
var mdast2nlcst = require('mdast-util-to-nlcst');
/**
* retext support for remark.
* Mutate-mode. Further transformers run on the NLCST tree.
*
* @param {Remark} remark - Origin processor.
* @param {Retext} retext - Destination processor.
* @param {VFile} file - Virtual file.
* @param {Function} parser - NLCST Parser.
* @return {NLCSTNode} - Tree.
*/
function enter(remark, retext, file) {
return mdast2nlcst(file, retext.Parser);
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);
}
}
/*
* Expose.
/**
* 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);
module.exports = bridge({
'name': 'retext',
'enter': enter
});
destination.run(tree, file, function (err) {
next(err);
});
};
}
/**
* 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;
return fn(destination);
}
/* Expose. */
module.exports = attacher;
{
"name": "remark-retext",
"version": "1.1.0",
"version": "2.0.0",
"description": "retext support for remark",
"license": "MIT",
"keywords": [
"markdown",
"remark",
"retext",
"mdast",
"remark",
"natural",
"language",
"nlcst",
"retext"
"nlcst"
],

@@ -22,26 +19,29 @@ "files": [

},
"bugs": "https://github.com/wooorm/remark-retext/issues",
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
],
"dependencies": {
"mdast-util-to-nlcst": "^2.0.0",
"unified-bridge": "^1.0.0"
"mdast-util-to-nlcst": "^3.0.0"
},
"devDependencies": {
"browserify": "^13.0.0",
"eslint": "^1.0.0",
"esmangle": "^1.0.0",
"browserify": "^13.0.1",
"eslint": "^2.0.0",
"esmangle": "^1.0.1",
"istanbul": "^0.4.0",
"jscs": "^2.0.0",
"jscs-jsdoc": "^1.0.0",
"remark": "^3.0.0",
"remark-comment-config": "^2.0.2",
"remark-github": "^2.0.0",
"remark-html": "^2.0.2",
"remark-lint": "^2.0.2",
"remark-slug": "^3.0.1",
"remark-validate-links": "^2.0.2",
"remark-yaml-config": "^2.0.0",
"retext": "^1.0.0",
"retext-equality": "^1.6.4",
"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",
"tape": "^4.0.0",
"vfile": "^1.2.0",
"unified": "^4.1.2",
"vfile-reporter": "^1.5.0"

@@ -48,0 +48,0 @@ },

# remark-retext [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]
[**retext**][retext] support for [**remark**][remark].
<!--lint disable heading-increment list-item-spacing-->
Bridge / mutate from [**remark**][remark] to [**retext**][retext].
## Installation

@@ -13,39 +15,36 @@

**remark-retext** is also available for [duo][duo-install], and as an
AMD, CommonJS, and globals module, [uncompressed and compressed][releases].
## Usage
```js
var remark = require('remark');
var retext = require('retext');
var report = require('vfile-reporter');
```javascript
var unified = require('unified');
var parse = require('remark-parse');
var lint = require('remark-lint');
var html = require('remark-html');
var remark2retext = require('remark-retext');
var english = require('retext-english');
var equality = require('retext-equality');
var remark2retext = require('remark-retext');
var stringify = require('remark-stringify');
var report = require('vfile-reporter');
remark()
unified()
.use(parse)
.use(lint)
.use(remark2retext, retext().use(equality))
.use(html)
.process('## Hey guys\n', function (err, file, doc) {
if (err) {
throw err;
} else {
process.stderr.write(report(file) + '\n');
process.stdout.write(doc);
}
.use(remark2retext, unified().use(english).use(equality))
.use(stringify)
.process('## Hello guys!', function (err, file) {
file.filename = 'example';
file.extension = 'md';
process.stderr.write(report(file) + '\n');
});
```
Yields:
**stderr**(4) yields:
```txt
<stdin>
1:1-1:12 warning First heading level should be `1` first-heading-level
1:8-1:12 warning `guys` may be insensitive, use `people`, `persons`, `folks` instead
example.md
1 warning Missing newline character at end of file final-newline
1-1:15 warning First heading level should be `1` first-heading-level
1-1:15 warning Don’t add a trailing `!` to headings no-heading-punctuation
10-1:14 warning `guys` may be insensitive, use `people`, `persons`, `folks` instead gals-men
⚠ 2 warnings
<h2>Hey guys</h2>
⚠ 4 warnings
```

@@ -55,11 +54,20 @@

### `remark.use(remark2retext, retext)`
### `origin.use(remark2retext, destination)`
[**retext**][retext] support for [**remark**][remark].
Either bridge or mutate from [**remark**][remark] ([MDAST][]) to
[**retext**][retext] ([NLCST][]).
**Parameters**:
###### `destination`
* `remark2retext` — This plug-in;
* `retext` ([`Processor`][retext]).
`destination` is either a parser or a processor.
If a [`Unified`][processor] processor is given, runs the destination
processor with the new NLCST tree, then, after running discards that
tree and continues on running the origin processor with the original
tree ([bridge-mode][bridge]).
If a parser (such as [**parse-latin**][latin], [**parse-english**][english],
or [**parse-dutch**][dutch]) is given, passes the tree to further
plug-ins (mutate-mode).
## License

@@ -71,6 +79,2 @@

[remark]: https://github.com/wooorm/remark
[retext]: https://github.com/wooorm/retext
[travis-badge]: https://img.shields.io/travis/wooorm/remark-retext.svg

@@ -80,14 +84,28 @@

[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/remark.svg
[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/remark-retext.svg
[codecov]: https://codecov.io/github/wooorm/remark
[codecov]: https://codecov.io/github/wooorm/remark-retext
[npm-install]: https://docs.npmjs.com/cli/install
[duo-install]: http://duojs.org/#getting-started
[license]: LICENSE
[releases]: https://github.com/wooorm/remark-retext/releases
[author]: http://wooorm.com
[license]: LICENSE
[mdast]: https://github.com/wooorm/mdast
[author]: http://wooorm.com
[remark]: https://github.com/wooorm/remark
[retext]: https://github.com/wooorm/retext
[processor]: https://github.com/wooorm/unified#processor
[bridge]: https://github.com/wooorm/unified#bridge
[nlcst]: https://github.com/wooorm/nlcst
[latin]: https://github.com/wooorm/parse-latin
[english]: https://github.com/wooorm/parse-english
[dutch]: https://github.com/wooorm/parse-dutch

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc