unified-bridge
Advanced tools
Comparing version 1.0.0 to 2.0.0
{ | ||
"name": "unified-bridge", | ||
"version": "1.0.0", | ||
"description": "Transform between two unified processors", | ||
"version": "2.0.0", | ||
"description": "Deprecated", | ||
"license": "MIT", | ||
"keywords": [ | ||
"unified", | ||
"bridge", | ||
"nlcst", | ||
"mdast", | ||
"hast", | ||
"retext", | ||
"remark" | ||
], | ||
"files": [ | ||
"index.js", | ||
"LICENSE" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wooorm/unified-bridge.git" | ||
}, | ||
"author": "Titus Wormer <tituswormer@gmail.com>", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"browserify": "^13.0.0", | ||
"eslint": "^1.0.0", | ||
"esmangle": "^1.0.0", | ||
"istanbul": "^0.4.0", | ||
"jscs": "^2.0.0", | ||
"jscs-jsdoc": "^1.0.0", | ||
"mdast-util-to-nlcst": "^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", | ||
"tape": "^4.0.0", | ||
"vfile": "^1.2.0", | ||
"vfile-reporter": "^1.5.0" | ||
}, | ||
"scripts": { | ||
"build-md": "remark . --quiet --frail", | ||
"build-bundle": "browserify index.js --bare -s unifiedBridge > unified-bridge.js", | ||
"build-mangle": "esmangle unified-bridge.js > unified-bridge.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", | ||
"test": "npm run build && npm run lint && npm run test-coverage" | ||
} | ||
"keywords": [], | ||
"files": [], | ||
"repository": "wooorm/unified-bridge", | ||
"author": "Titus Wormer <tituswormer@gmail.com>" | ||
} |
204
readme.md
@@ -1,201 +0,9 @@ | ||
# unified-bridge [![Build Status][travis-badge]][travis] [![Coverage Status][coveralls-badge]][coveralls] | ||
# unified-bridge | ||
[Unified][unified] bridges transform the syntax tree from one | ||
processor to that of another processor. Then, they apply the | ||
destination processors plug-ins on said tree, before mutating | ||
the original origin tree based on the modified destination tree | ||
and continuing on running the origin plug-ins. | ||
Deprecated. You can use multiple `unified` [plugins in bridge and/or mutate | ||
mode][p] directly. | ||
The exit step can be ignored. | ||
[See previous versions](https://github.com/wooorm/unified-bridge/commit/8961fb2). | ||
They can still be used. | ||
```txt | ||
origin:run destination:run origin:run | ||
origin tree ---- \ / -- destination tree -- \ / ---- origin tree | ||
/ \/ \/ \ | ||
/ \ | ||
/ enter bridge exit bridge \ | ||
/ \ | ||
doc doc | ||
origin:parse origin:compile | ||
``` | ||
## Installation | ||
[npm][npm-install]: | ||
```bash | ||
npm install unified-bridge | ||
``` | ||
**unified-bridge** is also available for [duo][duo-install], and as an | ||
AMD, CommonJS, and globals module, [uncompressed and compressed][releases]. | ||
## Usage | ||
In `remark-retext/index.js`: | ||
```js | ||
var bridge = require('unified-bridge'); | ||
var mdast2nlcst = require('mdast-util-to-nlcst'); | ||
function enter(origin, destination, file) { | ||
return mdast2nlcst(file, destination.Parser); | ||
} | ||
module.exports = bridge({ | ||
'name': 'retext', | ||
'enter': enter | ||
}); | ||
``` | ||
In `example.js`: | ||
```js | ||
var remark = require('remark'); | ||
var retext = require('retext'); | ||
var report = require('vfile-reporter'); | ||
var lint = require('remark-lint'); | ||
var html = require('remark-html'); | ||
var equality = require('retext-equality'); | ||
var remark2retext = require('remark-retext'); | ||
remark() | ||
.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); | ||
} | ||
}); | ||
``` | ||
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 | ||
⚠ 2 warnings | ||
<h2>Hey guys</h2> | ||
``` | ||
## API | ||
### `bridge(options)` | ||
Transform between two unified processors. | ||
**Parameters**: | ||
* `options` (`Object`): | ||
* `name` (`string`) | ||
— Name of destination syntax tree; | ||
* `enter` ([`Function`][doc-enter]) | ||
— Function invoked to transform the syntax tree of the | ||
origin processor into the syntax tree of the destination | ||
processor. | ||
* `exit` ([`Function?`][doc-exit], | ||
optional) | ||
— Function invoked to transform the syntax tree after processing by | ||
the destination processor back into a syntax tree suitable for | ||
the origin processor. | ||
**Returns**: `Bridge` — A bridge, which can be used as a plug-in | ||
for the origin parser you expect, accepting the expected destination | ||
processor as its options. | ||
**Throws**: `Error` — When `name` or `enter` is not `function`. | ||
### `function enter(origin, destination, file, node)` | ||
Transform `node`, which is a syntax tree produced by the `origin` | ||
processor, into a tree as if it was produced by the `destination` | ||
processor. | ||
**Parameters**: | ||
* `origin` ([`Processor`][doc-processor]) | ||
— Origin processor; | ||
* `destination` ([`Processor`][doc-processor]) | ||
— Destination processor; | ||
* `file` ([`VFile`][doc-vfile]) | ||
— Processed file; | ||
* `node` ([`Node`][doc-node]) | ||
— Syntax tree for `file` suitable for `origin`. | ||
**Returns**: [`Node`][doc-node] — Syntax tree of the given document | ||
but mutated into a tree suitable for `destination`. | ||
### `function exit(destination, origin, file, tree, node)` | ||
Transform `node`, which is a syntax tree produced by the `origin` | ||
processor, into a tree as if it was produced by the `destination` | ||
processor. | ||
**Parameters**: | ||
* `origin` ([`Processor`][doc-processor]) | ||
— Origin processor; | ||
* `destination` ([`Processor`][doc-processor]) | ||
— Destination processor; | ||
* `file` ([`VFile`][doc-vfile]) | ||
— Processed file; | ||
* `tree` ([`Node`][doc-node]) | ||
— Syntax tree for `file` suitable for `destination`, | ||
previously produced by `enter`; | ||
* `node` ([`Node`][doc-node]) | ||
— Syntax tree for `file` suitable for `origin`, originally given | ||
to `enter`, which should be manipulated based on changes in `tree`. | ||
## License | ||
[MIT][license] © [Titus Wormer][author] | ||
<!-- Definitions --> | ||
[unified]: https://github.com/wooorm/unified | ||
[travis-badge]: https://img.shields.io/travis/wooorm/unified-bridge.svg?style=flat | ||
[travis]: https://travis-ci.org/wooorm/unified-bridge | ||
[coveralls-badge]: https://img.shields.io/coveralls/wooorm/unified-bridge.svg?style=flat | ||
[coveralls]: https://coveralls.io/r/wooorm/unified-bridge?branch=master | ||
[npm-install]: https://docs.npmjs.com/cli/install | ||
[duo-install]: http://duojs.org/#getting-started | ||
[releases]: https://github.com/wooorm/unified-bridge/releases | ||
[license]: LICENSE | ||
[author]: http://wooorm.com | ||
[doc-enter]: #function-enterorigin-destination-file-node | ||
[doc-exit]: #function-exitdestination-origin-file-tree-node | ||
[doc-processor]: https://github.com/wooorm/unified#processorprocessor | ||
[doc-vfile]: https://github.com/wooorm/vfile#vfile | ||
[doc-node]: https://github.com/wooorm/unist#unist-nodes | ||
[p]: https://github.com/unifiedjs/unified#processing-between-syntaxes |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
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
0
521
2
0
1
10
1
1