This commit is contained in:
40
node_modules/rehype-remark/index.d.ts
generated
vendored
Normal file
40
node_modules/rehype-remark/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
declare function _exports(this: import("unified").Processor<import("unified").Settings>, ...settings: [Options?] | [import("unified").Processor<import("unified").Settings>, Options?]): void | import("unified").Transformer;
|
||||
export = _exports;
|
||||
export type Processor = import('unified').Processor;
|
||||
export type RunCallback = import('unified').RunCallback;
|
||||
export type Transformer = import('unified').Transformer;
|
||||
export type Node = import('unist').Node;
|
||||
export type MdastNode = import('mdast').Content;
|
||||
export type Parent = import('unist').Parent;
|
||||
export type Element = import('hast').Element;
|
||||
export type Context = {
|
||||
nodeById: {
|
||||
[x: string]: Element;
|
||||
};
|
||||
baseFound: boolean;
|
||||
frozenBaseUrl: string | null;
|
||||
wrapText: boolean;
|
||||
qNesting: number;
|
||||
handlers: {
|
||||
[x: string]: Handle;
|
||||
};
|
||||
document: boolean | undefined;
|
||||
checked: string;
|
||||
unchecked: string;
|
||||
quotes: Array<string>;
|
||||
};
|
||||
export type HWithProps = (node: Node, type: string, props?: Properties, children?: string | Array<MdastNode>) => MdastNode;
|
||||
export type HWithoutProps = (node: Node, type: string, children?: string | Array<MdastNode>) => MdastNode;
|
||||
export type Properties = Record<string, unknown>;
|
||||
export type H = HWithProps & HWithoutProps & Context;
|
||||
export type Handle = (h: H, node: any, parent?: Parent) => MdastNode | Array<MdastNode> | void;
|
||||
export type Options = {
|
||||
handlers?: {
|
||||
[x: string]: Handle;
|
||||
};
|
||||
document?: boolean;
|
||||
newlines?: boolean;
|
||||
checked?: string;
|
||||
unchecked?: string;
|
||||
quotes?: Array<string>;
|
||||
};
|
||||
120
node_modules/rehype-remark/index.js
generated
vendored
Normal file
120
node_modules/rehype-remark/index.js
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* @typedef {import('unified').Processor} Processor
|
||||
* @typedef {import('unified').RunCallback} RunCallback
|
||||
* @typedef {import('unified').Transformer} Transformer
|
||||
* @typedef {import('unist').Node} Node
|
||||
*/
|
||||
|
||||
var hast2mdast = require('hast-util-to-mdast')
|
||||
|
||||
/**
|
||||
* Attacher.
|
||||
*
|
||||
* If a destination is given, runs the destination with the new mdast
|
||||
* tree (bridge-mode). Without destination, returns the mdast tree: further
|
||||
* plugins run on that tree (mutate-mode).
|
||||
*
|
||||
* @param destination Optional unified processor.
|
||||
* @param options Options passed to `hast-util-to-mdast`.
|
||||
*/
|
||||
module.exports =
|
||||
/**
|
||||
* @type {import('unified').Plugin<[Options?]|[Processor, Options?]>}
|
||||
*/
|
||||
(
|
||||
/**
|
||||
* @param {Processor|Options} [destination]
|
||||
* @param {Options} [options]
|
||||
*/
|
||||
function (destination, options) {
|
||||
/** @type {Options|undefined} */
|
||||
var settings
|
||||
/** @type {Processor|undefined} */
|
||||
var processor
|
||||
|
||||
if (typeof destination === 'function') {
|
||||
processor = destination
|
||||
settings = options || {}
|
||||
} else {
|
||||
settings = destination || {}
|
||||
}
|
||||
|
||||
if (settings.document === undefined || settings.document === null) {
|
||||
settings = Object.assign({}, settings, {document: true})
|
||||
}
|
||||
|
||||
return processor ? bridge(processor, settings) : mutate(settings)
|
||||
}
|
||||
)
|
||||
|
||||
/**
|
||||
* Bridge-mode.
|
||||
* Runs the destination with the new mdast tree.
|
||||
* @param {Processor} destination
|
||||
* @param {Options} [options]
|
||||
* @returns {Transformer}
|
||||
*/
|
||||
function bridge(destination, options) {
|
||||
return transformer
|
||||
/** @type {Transformer} */
|
||||
function transformer(node, file, next) {
|
||||
destination.run(hast2mdast(node, options), file, done)
|
||||
/** @type {RunCallback} */
|
||||
function done(err) {
|
||||
// @ts-expect-error: `unified` should accept 1 arg for next.
|
||||
// See: <https://github.com/unifiedjs/unified/pull/141#issuecomment-871239574>
|
||||
next(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutate-mode.
|
||||
* Further transformers run on the mdast tree.
|
||||
*
|
||||
* @param {Options} [options]
|
||||
* @returns {Transformer}
|
||||
*/
|
||||
function mutate(options) {
|
||||
return transformer
|
||||
/** @param {Node} node */
|
||||
function transformer(node) {
|
||||
return hast2mdast(node, options)
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the following JSDoc block when upgrading hast-util-to-mdast to version 8.
|
||||
// Import these types from hast-util-to-mdast when version 8 released.
|
||||
/**
|
||||
* @typedef {import('mdast').Content} MdastNode
|
||||
* @typedef {import('unist').Parent} Parent
|
||||
* @typedef {import('hast').Element} Element
|
||||
*
|
||||
* @typedef Context
|
||||
* @property {Object.<string, Element>} nodeById
|
||||
* @property {boolean} baseFound
|
||||
* @property {string|null} frozenBaseUrl
|
||||
* @property {boolean} wrapText
|
||||
* @property {number} qNesting
|
||||
* @property {Object.<string, Handle>} handlers
|
||||
* @property {boolean|undefined} document
|
||||
* @property {string} checked
|
||||
* @property {string} unchecked
|
||||
* @property {Array.<string>} quotes
|
||||
*
|
||||
* @typedef {(node: Node, type: string, props?: Properties, children?: string|Array.<MdastNode>) => MdastNode} HWithProps
|
||||
* @typedef {(node: Node, type: string, children?: string|Array.<MdastNode>) => MdastNode} HWithoutProps
|
||||
* @typedef {Record<string, unknown>} Properties*
|
||||
* @typedef {HWithProps & HWithoutProps & Context} H
|
||||
* @typedef {(h: H, node: any, parent?: Parent) => MdastNode|Array.<MdastNode>|void} Handle
|
||||
*
|
||||
* @typedef Options
|
||||
* @property {Object.<string, Handle>} [handlers]
|
||||
* @property {boolean} [document]
|
||||
* @property {boolean} [newlines=false]
|
||||
* @property {string} [checked='[x]']
|
||||
* @property {string} [unchecked='[ ]']
|
||||
* @property {Array.<string>} [quotes=['"']]
|
||||
*/
|
||||
22
node_modules/rehype-remark/license
generated
vendored
Normal file
22
node_modules/rehype-remark/license
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2017 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.
|
||||
101
node_modules/rehype-remark/package.json
generated
vendored
Normal file
101
node_modules/rehype-remark/package.json
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
{
|
||||
"name": "rehype-remark",
|
||||
"version": "8.1.1",
|
||||
"description": "rehype plugin to transform to remark",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"unified",
|
||||
"rehype",
|
||||
"rehype-plugin",
|
||||
"remark",
|
||||
"remark-plugin",
|
||||
"html",
|
||||
"markdown",
|
||||
"hast",
|
||||
"mdast"
|
||||
],
|
||||
"repository": "rehypejs/rehype-remark",
|
||||
"bugs": "https://github.com/rehypejs/rehype-remark/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/hast": "^2.0.0",
|
||||
"@types/mdast": "^3.0.0",
|
||||
"@types/unist": "^2.0.0",
|
||||
"hast-util-to-mdast": "^7.0.0"
|
||||
},
|
||||
"types": "index.d.ts",
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/tape": "^4.0.0",
|
||||
"browserify": "^17.0.0",
|
||||
"nyc": "^15.0.0",
|
||||
"prettier": "^2.0.0",
|
||||
"rehype-parse": "^7.0.0",
|
||||
"rehype-stringify": "^8.0.0",
|
||||
"remark-cli": "^9.0.0",
|
||||
"remark-preset-wooorm": "^8.0.0",
|
||||
"remark-stringify": "^9.0.0",
|
||||
"rimraf": "^3.0.0",
|
||||
"tape": "^5.0.0",
|
||||
"tinyify": "^3.0.0",
|
||||
"type-coverage": "^2.0.0",
|
||||
"typescript": "^4.0.0",
|
||||
"unified": "^9.0.0",
|
||||
"xo": "^0.36.0"
|
||||
},
|
||||
"scripts": {
|
||||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
|
||||
"build-types": "rimraf \"*.d.ts\" && tsc && type-coverage",
|
||||
"build-bundle": "browserify . -s rehypeRemark -o rehype-remark.js",
|
||||
"build-mangle": "browserify . -s rehypeRemark -o rehype-remark.min.js -p tinyify",
|
||||
"build": "npm run build-types && 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": [
|
||||
"rehype-remark.js"
|
||||
]
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"preset-wooorm"
|
||||
]
|
||||
},
|
||||
"typeCoverage": {
|
||||
"atLeast": 100,
|
||||
"detail": true,
|
||||
"strict": true,
|
||||
"ignoreCatch": true,
|
||||
"ignoreFiles": [
|
||||
"index.d.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
174
node_modules/rehype-remark/readme.md
generated
vendored
Normal file
174
node_modules/rehype-remark/readme.md
generated
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
# rehype-remark
|
||||
|
||||
[![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]
|
||||
|
||||
[**rehype**][rehype] plugin to bridge or mutate to [**remark**][remark].
|
||||
|
||||
Tiny wrapper around [`hast-util-to-mdast`][to-mdast].
|
||||
|
||||
## Note!
|
||||
|
||||
This plugin is ready for the new parser in remark
|
||||
([`remarkjs/remark#536`](https://github.com/remarkjs/remark/pull/536)).
|
||||
No change is needed: it works exactly the same now as it did before!
|
||||
|
||||
## Install
|
||||
|
||||
[npm][]:
|
||||
|
||||
```sh
|
||||
npm install rehype-remark
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
Say our `example.js` looks as follows:
|
||||
|
||||
```js
|
||||
var unified = require('unified')
|
||||
var createStream = require('unified-stream')
|
||||
var parse = require('rehype-parse')
|
||||
var rehype2remark = require('rehype-remark')
|
||||
var stringify = require('remark-stringify')
|
||||
|
||||
var processor = unified().use(parse).use(rehype2remark).use(stringify)
|
||||
|
||||
process.stdin.pipe(createStream(processor)).pipe(process.stdout)
|
||||
```
|
||||
|
||||
Now, when running the following in a terminal (`2>/dev/null` is just to
|
||||
silence Curl’s debugging output):
|
||||
|
||||
```sh
|
||||
curl https://example.com 2>/dev/null | node example.js
|
||||
```
|
||||
|
||||
**stdout**(4) yields:
|
||||
|
||||
```markdown
|
||||
# Example Domain
|
||||
|
||||
This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.
|
||||
|
||||
[More information...](https://www.iana.org/domains/example)
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `origin.use(rehype2remark[, destination][, options])`
|
||||
|
||||
[**rehype**][rehype] ([hast][]) plugin to bridge or mutate to
|
||||
[**remark**][remark] ([mdast][]).
|
||||
|
||||
###### `destination`
|
||||
|
||||
If given ([`Unified`][processor]), runs the destination processor with the new
|
||||
**mdast** tree, then, after running discards that tree and continues on running
|
||||
the origin processor with the original **hast** tree ([bridge-mode][bridge]).
|
||||
Otherwise, passes the tree to further plugins (mutate-mode).
|
||||
|
||||
###### `options`
|
||||
|
||||
Options are passed to [`hast-util-to-mdast`][to-mdast].
|
||||
Note that [`options.document`][document] defaults to `true` in `rehype-remark`,
|
||||
as this plugin is mostly used with blocks.
|
||||
|
||||
## Security
|
||||
|
||||
Use of `rehype-remark` can open you up to a [cross-site scripting (XSS)][xss]
|
||||
attack if the tree is unsafe.
|
||||
Use [`rehype-sanitize`][sanitize] to make the tree safe.
|
||||
|
||||
## Related
|
||||
|
||||
* [`remark-rehype`](https://github.com/remarkjs/remark-rehype)
|
||||
— Transform Markdown ([**mdast**][mdast]) to HTML ([**hast**][hast])
|
||||
* [`rehype-retext`](https://github.com/rehypejs/rehype-retext)
|
||||
— Transform HTML ([**hast**][hast]) to natural language ([**nlcst**][nlcst])
|
||||
* [`remark-retext`](https://github.com/remarkjs/remark-retext)
|
||||
— Transform Markdown ([**mdast**][mdast]) to natural language
|
||||
([**nlcst**][nlcst])
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`rehypejs/.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, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[build-badge]: https://github.com/rehypejs/rehype-remark/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/rehypejs/rehype-remark/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype-remark.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/rehypejs/rehype-remark
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/rehype-remark.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/rehype-remark
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/rehype-remark.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=rehype-remark
|
||||
|
||||
[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/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/rehypejs/rehype/discussions
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/rehypejs/.github
|
||||
|
||||
[contributing]: https://github.com/rehypejs/.github/blob/HEAD/contributing.md
|
||||
|
||||
[support]: https://github.com/rehypejs/.github/blob/HEAD/support.md
|
||||
|
||||
[coc]: https://github.com/rehypejs/.github/blob/HEAD/code-of-conduct.md
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[rehype]: https://github.com/rehypejs/rehype
|
||||
|
||||
[mdast]: https://github.com/syntax-tree/mdast
|
||||
|
||||
[hast]: https://github.com/syntax-tree/hast
|
||||
|
||||
[nlcst]: https://github.com/syntax-tree/nlcst
|
||||
|
||||
[processor]: https://github.com/unifiedjs/unified#processor
|
||||
|
||||
[bridge]: https://github.com/unifiedjs/unified#processing-between-syntaxes
|
||||
|
||||
[to-mdast]: https://github.com/syntax-tree/hast-util-to-mdast
|
||||
|
||||
[document]: https://github.com/syntax-tree/hast-util-to-mdast#optionsdocument
|
||||
|
||||
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
|
||||
|
||||
[sanitize]: https://github.com/rehypejs/rehype-sanitize
|
||||
Reference in New Issue
Block a user