This commit is contained in:
43
node_modules/remark-rehype/index.js
generated
vendored
Normal file
43
node_modules/remark-rehype/index.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
'use strict'
|
||||
|
||||
var mdast2hast = require('mdast-util-to-hast')
|
||||
|
||||
module.exports = remark2rehype
|
||||
|
||||
// Attacher.
|
||||
// If a destination is given, runs the destination with the new hast tree
|
||||
// (bridge mode).
|
||||
// Without destination, returns the tree: further plugins run on that tree
|
||||
// (mutate mode).
|
||||
function remark2rehype(destination, options) {
|
||||
if (destination && !destination.process) {
|
||||
options = destination
|
||||
destination = null
|
||||
}
|
||||
|
||||
return destination ? bridge(destination, options) : mutate(options)
|
||||
}
|
||||
|
||||
// Bridge mode.
|
||||
// Runs the destination with the new hast tree.
|
||||
function bridge(destination, options) {
|
||||
return transformer
|
||||
|
||||
function transformer(node, file, next) {
|
||||
destination.run(mdast2hast(node, options), file, done)
|
||||
|
||||
function done(err) {
|
||||
next(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mutate-mode.
|
||||
// Further transformers run on the hast tree.
|
||||
function mutate(options) {
|
||||
return transformer
|
||||
|
||||
function transformer(node) {
|
||||
return mdast2hast(node, options)
|
||||
}
|
||||
}
|
||||
22
node_modules/remark-rehype/license
generated
vendored
Normal file
22
node_modules/remark-rehype/license
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2016 Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
78
node_modules/remark-rehype/package.json
generated
vendored
Normal file
78
node_modules/remark-rehype/package.json
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"name": "remark-rehype",
|
||||
"version": "4.0.1",
|
||||
"description": "remark plugin to transform to rehype",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"unified",
|
||||
"remark",
|
||||
"rehype",
|
||||
"plugin",
|
||||
"html",
|
||||
"hast",
|
||||
"mdast",
|
||||
"markdown"
|
||||
],
|
||||
"repository": "remarkjs/remark-rehype",
|
||||
"bugs": "https://github.com/remarkjs/remark-rehype/issues",
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"John Otander <johnotander@gmail.com> (https://johno.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"mdast-util-to-hast": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.0.0",
|
||||
"nyc": "^14.0.0",
|
||||
"prettier": "^1.0.0",
|
||||
"rehype-stringify": "^6.0.0",
|
||||
"remark-cli": "^6.0.0",
|
||||
"remark-parse": "^6.0.0",
|
||||
"remark-preset-wooorm": "^5.0.0",
|
||||
"remark-stringify": "^6.0.0",
|
||||
"tape": "^4.0.0",
|
||||
"tinyify": "^2.0.0",
|
||||
"unified": "^7.0.0",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"scripts": {
|
||||
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
|
||||
"build-bundle": "browserify . -s remarkRehype > remark-rehype.js",
|
||||
"build-mangle": "browserify . -s remarkRehype -p tinyify > remark-rehype.min.js",
|
||||
"build": "npm run build-bundle && npm run build-mangle",
|
||||
"test-api": "node test",
|
||||
"test-coverage": "nyc --reporter lcov tape test.js",
|
||||
"test": "npm run format && npm run build && npm run test-coverage"
|
||||
},
|
||||
"nyc": {
|
||||
"check-coverage": true,
|
||||
"lines": 100,
|
||||
"functions": 100,
|
||||
"branches": 100
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"trailingComma": "none"
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"esnext": false,
|
||||
"ignores": [
|
||||
"remark-rehype.js"
|
||||
]
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"preset-wooorm"
|
||||
]
|
||||
}
|
||||
}
|
||||
182
node_modules/remark-rehype/readme.md
generated
vendored
Normal file
182
node_modules/remark-rehype/readme.md
generated
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
# remark-rehype
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
|
||||
[**remark**][remark] plugin to bridge or mutate to [**rehype**][rehype].
|
||||
|
||||
> Note: `remark-rehype` doesn’t deal with HTML inside the Markdown.
|
||||
> You’ll need [`rehype-raw`][raw] if you’re planning on doing that.
|
||||
|
||||
## Install
|
||||
|
||||
[npm][]:
|
||||
|
||||
```sh
|
||||
npm install remark-rehype
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
Say we have the following file, `example.md`:
|
||||
|
||||
```markdown
|
||||
# Hello world
|
||||
|
||||
> Block quote.
|
||||
|
||||
Some _emphasis_, **importance**, and `code`.
|
||||
```
|
||||
|
||||
And our script, `example.js`, looks as follows:
|
||||
|
||||
```js
|
||||
var vfile = require('to-vfile')
|
||||
var report = require('vfile-reporter')
|
||||
var unified = require('unified')
|
||||
var markdown = require('remark-parse')
|
||||
var remark2rehype = require('remark-rehype')
|
||||
var doc = require('rehype-document')
|
||||
var format = require('rehype-format')
|
||||
var html = require('rehype-stringify')
|
||||
|
||||
unified()
|
||||
.use(markdown)
|
||||
.use(remark2rehype)
|
||||
.use(doc)
|
||||
.use(format)
|
||||
.use(html)
|
||||
.process(vfile.readSync('example.md'), function(err, file) {
|
||||
console.error(report(err || file))
|
||||
console.log(String(file))
|
||||
})
|
||||
```
|
||||
|
||||
Now, running `node example` yields:
|
||||
|
||||
```html
|
||||
example.md: no issues found
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>example</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello world</h1>
|
||||
<blockquote>
|
||||
<p>Block quote.</p>
|
||||
</blockquote>
|
||||
<p>Some <em>emphasis</em>, <strong>importance</strong>, and <code>code</code>.</p>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `origin.use(remark2rehype[, destination][, options])`
|
||||
|
||||
[**remark**][remark] ([**mdast**][mdast]) plugin to bridge or mutate to
|
||||
[**rehype**][rehype] ([**hast**][hast]).
|
||||
|
||||
###### `destination`
|
||||
|
||||
If a [`Unified`][processor] processor is given, runs the destination processor
|
||||
with the new hast tree, then, after running discards that tree and continues on
|
||||
running the origin processor with the original tree ([*bridge mode*][bridge]).
|
||||
Otherwise, passes the tree to further plugins (*mutate mode*).
|
||||
|
||||
###### `options`
|
||||
|
||||
Passed to [`mdast-util-to-hast`][to-hast].
|
||||
|
||||
## Related
|
||||
|
||||
* [`rehype-raw`][raw]
|
||||
— Properly deal with HTML in Markdown (used after `remark-rehype`)
|
||||
* [`rehype-remark`](https://github.com/rehypejs/rehype-remark)
|
||||
— Transform HTML ([hast][]) to Markdown ([mdast][])
|
||||
* [`rehype-retext`](https://github.com/rehypejs/rehype-retext)
|
||||
— Transform HTML ([hast][]) to natural language ([nlcst][])
|
||||
* [`remark-retext`](https://github.com/remarkjs/remark-retext)
|
||||
— Transform Markdown ([mdast][]) to natural language ([nlcst][])
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
|
||||
This project has a [Code of Conduct][coc].
|
||||
By interacting with this repository, organisation, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[build-badge]: https://img.shields.io/travis/remarkjs/remark-rehype/master.svg
|
||||
|
||||
[build]: https://travis-ci.org/remarkjs/remark-rehype
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-rehype.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-rehype
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-rehype.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-rehype
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-rehype.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-rehype
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
|
||||
|
||||
[chat]: https://spectrum.chat/unified/remark
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/master/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/master/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/master/code-of-conduct.md
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[processor]: https://github.com/unifiedjs/unified#processor
|
||||
|
||||
[bridge]: https://github.com/unifiedjs/unified#processing-between-syntaxes
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[rehype]: https://github.com/rehypejs/rehype
|
||||
|
||||
[raw]: https://github.com/rehypejs/rehype-raw
|
||||
|
||||
[mdast]: https://github.com/syntax-tree/mdast
|
||||
|
||||
[hast]: https://github.com/syntax-tree/hast
|
||||
|
||||
[nlcst]: https://github.com/syntax-tree/nlcst
|
||||
|
||||
[to-hast]: https://github.com/syntax-tree/mdast-util-to-hast#tohastnode-options
|
||||
Reference in New Issue
Block a user