remark-retext
Advanced tools
Comparing version 5.0.1 to 6.0.0
@@ -1,3 +0,2 @@ | ||
export default remarkRetext | ||
export type Options = import('./lib/index.js').Options | ||
import remarkRetext from './lib/index.js' | ||
export type {Options} from './lib/index.js' | ||
export {default} from './lib/index.js' |
@@ -5,4 +5,2 @@ /** | ||
import remarkRetext from './lib/index.js' | ||
export default remarkRetext | ||
export {default} from './lib/index.js' |
@@ -1,32 +0,85 @@ | ||
export default remarkRetext | ||
export type Node = import('unist').Node | ||
export type MdastRoot = import('mdast').Root | ||
export type ParserInstance = import('mdast-util-to-nlcst').ParserInstance | ||
export type ParserConstructor = import('mdast-util-to-nlcst').ParserConstructor | ||
export type Options = import('mdast-util-to-nlcst').Options | ||
export type Processor = import('unified').Processor<any, any, any, any> | ||
export type Parser = import('unified').Parser<any> | ||
/** | ||
* Plugin to support retext. | ||
* Bridge or mutate to retext. | ||
* | ||
* * If a destination processor is given, runs the plugins attached to it with | ||
* the new nlcst tree (bridge-mode). | ||
* This given processor must have a parser attached (this can be done by | ||
* using the plugin `retext-english` or similar) and should use other retext | ||
* plugins. | ||
* * If a parser is given, runs further plugins attached to the same processor | ||
* with the new tree (mutate-mode). | ||
* Such parsers are exported by packages like `retext-english` as `Parser`. | ||
* You should use other retext plugins after `remark-retext`. | ||
* ###### Notes | ||
* | ||
* @param destination | ||
* Either a processor (`unified().use(retextEnglish)…`) or a parser. | ||
* @param options | ||
* Configuration passed to `mdast-util-to-nlcst`. | ||
* * if a processor is given, uses its parser to create a new nlcst tree, | ||
* then runs the plugins attached to with that ([*bridge mode*][bridge]); | ||
* you can add a parser to processor for example with `retext-english`; other | ||
* plugins used on the processor should be retext plugins | ||
* * if a parser is given, uses it to create a new nlcst tree, and returns | ||
* it (*mutate mode*); you can get a parser by importing `Parser` from | ||
* `retext-english` for example; other plugins used after `remarkRetext` | ||
* should be retext plugins | ||
* | ||
* @overload | ||
* @param {Processor} processor | ||
* @param {Options | null | undefined} [options] | ||
* @returns {TransformBridge} | ||
* | ||
* @overload | ||
* @param {Parser} parser | ||
* @param {Options | null | undefined} [options] | ||
* @returns {TransformMutate} | ||
* | ||
* @param {Parser | Processor} destination | ||
* Parser or processor (required). | ||
* @param {Options | null | undefined} [options] | ||
* Configuration (optional). | ||
* @returns {TransformBridge | TransformMutate} | ||
* Transform. | ||
*/ | ||
declare const remarkRetext: import('unified').Plugin< | ||
[Processor, Options?] | [Processor], | ||
MdastRoot, | ||
MdastRoot | ||
> & | ||
import('unified').Plugin<[Parser, Options?] | [Parser], MdastRoot, Node> | ||
export default function remarkRetext(processor: Processor, options?: Options | null | undefined): TransformBridge; | ||
/** | ||
* Bridge or mutate to retext. | ||
* | ||
* ###### Notes | ||
* | ||
* * if a processor is given, uses its parser to create a new nlcst tree, | ||
* then runs the plugins attached to with that ([*bridge mode*][bridge]); | ||
* you can add a parser to processor for example with `retext-english`; other | ||
* plugins used on the processor should be retext plugins | ||
* * if a parser is given, uses it to create a new nlcst tree, and returns | ||
* it (*mutate mode*); you can get a parser by importing `Parser` from | ||
* `retext-english` for example; other plugins used after `remarkRetext` | ||
* should be retext plugins | ||
* | ||
* @overload | ||
* @param {Processor} processor | ||
* @param {Options | null | undefined} [options] | ||
* @returns {TransformBridge} | ||
* | ||
* @overload | ||
* @param {Parser} parser | ||
* @param {Options | null | undefined} [options] | ||
* @returns {TransformMutate} | ||
* | ||
* @param {Parser | Processor} destination | ||
* Parser or processor (required). | ||
* @param {Options | null | undefined} [options] | ||
* Configuration (optional). | ||
* @returns {TransformBridge | TransformMutate} | ||
* Transform. | ||
*/ | ||
export default function remarkRetext(parser: Parser, options?: Options | null | undefined): TransformMutate; | ||
export type MdastRoot = import('mdast').Root; | ||
export type Options = import('mdast-util-to-nlcst').Options; | ||
export type ParserConstructor = import('mdast-util-to-nlcst').ParserConstructor; | ||
export type ParserInstance = import('mdast-util-to-nlcst').ParserInstance; | ||
export type NlcstRoot = import('nlcst').Root; | ||
export type Processor = import('unified').Processor<NlcstRoot>; | ||
export type VFile = import('vfile').VFile; | ||
export type Parser = ParserConstructor | ParserInstance; | ||
/** | ||
* Bridge-mode. | ||
* | ||
* Runs the destination with the new nlcst tree. | ||
* Discards result. | ||
*/ | ||
export type TransformBridge = (tree: MdastRoot, file: VFile) => Promise<undefined>; | ||
/** | ||
* Mutate-mode. | ||
* | ||
* Further transformers run on the nlcst tree. | ||
*/ | ||
export type TransformMutate = (tree: MdastRoot, file: VFile) => NlcstRoot; |
158
lib/index.js
/** | ||
* @typedef {import('unist').Node} Node | ||
* @typedef {import('mdast').Root} MdastRoot | ||
* @typedef {import('mdast-util-to-nlcst').Options} Options | ||
* @typedef {import('mdast-util-to-nlcst').ParserConstructor} ParserConstructor | ||
* @typedef {import('mdast-util-to-nlcst').ParserInstance} ParserInstance | ||
* @typedef {import('mdast-util-to-nlcst').ParserConstructor} ParserConstructor | ||
* @typedef {import('mdast-util-to-nlcst').Options} Options | ||
* @typedef {import('unified').Processor<any, any, any, any>} Processor | ||
* @typedef {import('unified').Parser<any>} Parser | ||
* @typedef {import('nlcst').Root} NlcstRoot | ||
* @typedef {import('unified').Processor<NlcstRoot>} Processor | ||
* @typedef {import('vfile').VFile} VFile | ||
*/ | ||
/** | ||
* @typedef {ParserConstructor | ParserInstance} Parser | ||
* | ||
* @callback TransformBridge | ||
* Bridge-mode. | ||
* | ||
* Runs the destination with the new nlcst tree. | ||
* Discards result. | ||
* @param {MdastRoot} tree | ||
* Tree. | ||
* @param {VFile} file | ||
* File. | ||
* @returns {Promise<undefined>} | ||
* Nothing. | ||
* | ||
* @callback TransformMutate | ||
* Mutate-mode. | ||
* | ||
* Further transformers run on the nlcst tree. | ||
* | ||
* @param {MdastRoot} tree | ||
* Tree. | ||
* @param {VFile} file | ||
* File. | ||
* @returns {NlcstRoot} | ||
* Tree (nlcst). | ||
*/ | ||
import {toNlcst} from 'mdast-util-to-nlcst' | ||
import {ParseLatin} from 'parse-latin' | ||
/** | ||
* Plugin to support retext. | ||
* Bridge or mutate to retext. | ||
* | ||
* * If a destination processor is given, runs the plugins attached to it with | ||
* the new nlcst tree (bridge-mode). | ||
* This given processor must have a parser attached (this can be done by | ||
* using the plugin `retext-english` or similar) and should use other retext | ||
* plugins. | ||
* * If a parser is given, runs further plugins attached to the same processor | ||
* with the new tree (mutate-mode). | ||
* Such parsers are exported by packages like `retext-english` as `Parser`. | ||
* You should use other retext plugins after `remark-retext`. | ||
* ###### Notes | ||
* | ||
* @param destination | ||
* Either a processor (`unified().use(retextEnglish)…`) or a parser. | ||
* @param options | ||
* Configuration passed to `mdast-util-to-nlcst`. | ||
* * if a processor is given, uses its parser to create a new nlcst tree, | ||
* then runs the plugins attached to with that ([*bridge mode*][bridge]); | ||
* you can add a parser to processor for example with `retext-english`; other | ||
* plugins used on the processor should be retext plugins | ||
* * if a parser is given, uses it to create a new nlcst tree, and returns | ||
* it (*mutate mode*); you can get a parser by importing `Parser` from | ||
* `retext-english` for example; other plugins used after `remarkRetext` | ||
* should be retext plugins | ||
* | ||
* @overload | ||
* @param {Processor} processor | ||
* @param {Options | null | undefined} [options] | ||
* @returns {TransformBridge} | ||
* | ||
* @overload | ||
* @param {Parser} parser | ||
* @param {Options | null | undefined} [options] | ||
* @returns {TransformMutate} | ||
* | ||
* @param {Parser | Processor} destination | ||
* Parser or processor (required). | ||
* @param {Options | null | undefined} [options] | ||
* Configuration (optional). | ||
* @returns {TransformBridge | TransformMutate} | ||
* Transform. | ||
*/ | ||
const remarkRetext = | ||
/** | ||
* @type {(import('unified').Plugin<[Processor, Options?]|[Processor], MdastRoot, MdastRoot> & import('unified').Plugin<[Parser, Options?]|[Parser], MdastRoot, Node>)} | ||
*/ | ||
( | ||
export default function remarkRetext(destination, options) { | ||
if (!destination) { | ||
throw new Error( | ||
'Expected `parser` (such as from `parse-english`) or `processor` (a unified pipeline) as `destination`' | ||
) | ||
} | ||
if ('run' in destination) { | ||
const processor = destination.freeze() | ||
/** | ||
* @param {Processor|Parser} destination | ||
* @param {Options|undefined} options | ||
* @type {TransformBridge} | ||
*/ | ||
function (destination, options) { | ||
return destination && 'run' in destination | ||
? bridge(destination, options) | ||
: mutate(destination, options) | ||
return async function (tree, file) { | ||
const parser = parserFromRetextParse(processor) | ||
const nlcstTree = toNlcst(tree, file, parser, options) | ||
await processor.run(nlcstTree, file) | ||
} | ||
) | ||
} | ||
export default remarkRetext | ||
const parser = destination | ||
/** | ||
* Mutate-mode. | ||
* Further transformers run on the nlcst tree. | ||
* | ||
* @type {import('unified').Plugin<[Parser, Options?], MdastRoot, Node>} | ||
*/ | ||
function mutate(parser, options) { | ||
// Assume the parser is a retext parser. | ||
const Parser = /** @type {ParserInstance|ParserConstructor} */ (parser) | ||
return (node, file) => toNlcst(node, file, Parser, options) | ||
/** | ||
* @type {TransformMutate} | ||
*/ | ||
return function (tree, file) { | ||
return toNlcst(tree, file, parser, options) | ||
} | ||
} | ||
/** | ||
* Bridge-mode. | ||
* Runs the destination with the new nlcst tree. | ||
* | ||
* @type {import('unified').Plugin<[Processor, Options?], MdastRoot>} | ||
* @param {Processor} processor | ||
* @returns {ParseLatin} | ||
*/ | ||
function bridge(destination, options) { | ||
return (node, file, next) => { | ||
// Assume the parser is a retext parser. | ||
const Parser = /** @type {ParserConstructor|ParserInstance} */ ( | ||
destination.freeze().Parser | ||
) | ||
function parserFromRetextParse(processor) { | ||
const parser = new ParseLatin() | ||
add( | ||
parser.tokenizeParagraphPlugins, | ||
processor.data('nlcstParagraphExtensions') | ||
) | ||
add(parser.tokenizeRootPlugins, processor.data('nlcstRootExtensions')) | ||
add(parser.tokenizeSentencePlugins, processor.data('nlcstSentenceExtensions')) | ||
destination.run(toNlcst(node, file, Parser, options), file, (error) => { | ||
next(error) | ||
}) | ||
return parser | ||
/** | ||
* @template T | ||
* @param {Array<T>} list | ||
* @param {Array<T> | undefined} values | ||
*/ | ||
function add(list, values) { | ||
/* c8 ignore next -- plugins like `retext-emoji`. */ | ||
if (values) list.unshift(...values) | ||
} | ||
} |
{ | ||
"name": "remark-retext", | ||
"version": "5.0.1", | ||
"version": "6.0.0", | ||
"description": "remark plugin to support retext", | ||
"license": "MIT", | ||
"keywords": [ | ||
"unified", | ||
"markdown", | ||
"mdast", | ||
"natural language", | ||
"nlcst", | ||
"plugin", | ||
"prose", | ||
"remark", | ||
"remark-plugin", | ||
"retext", | ||
"plugin", | ||
"mdast", | ||
"markdown", | ||
"nlcst", | ||
"natural language", | ||
"prose" | ||
"unified" | ||
], | ||
@@ -30,4 +30,3 @@ "repository": "remarkjs/remark-retext", | ||
"type": "module", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"exports": "./index.js", | ||
"files": [ | ||
@@ -39,44 +38,43 @@ "lib/", | ||
"dependencies": { | ||
"@types/mdast": "^3.0.0", | ||
"@types/unist": "^2.0.0", | ||
"mdast-util-to-nlcst": "^5.0.0", | ||
"unified": "^10.0.0" | ||
"@types/mdast": "^4.0.0", | ||
"@types/nlcst": "^2.0.0", | ||
"mdast-util-to-nlcst": "^7.0.0", | ||
"parse-latin": "^7.0.0", | ||
"unified": "^11.0.0", | ||
"vfile": "^6.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/tape": "^4.0.0", | ||
"c8": "^7.0.0", | ||
"prettier": "^2.0.0", | ||
"remark-cli": "^10.0.0", | ||
"remark-parse": "^10.0.0", | ||
"@types/node": "^20.0.0", | ||
"c8": "^8.0.0", | ||
"parse-english": "^7.0.0", | ||
"prettier": "^3.0.0", | ||
"remark-cli": "^11.0.0", | ||
"remark-parse": "^11.0.0", | ||
"remark-preset-wooorm": "^9.0.0", | ||
"remark-stringify": "^10.0.0", | ||
"retext-english": "^4.0.0", | ||
"retext-stringify": "^3.0.0", | ||
"rimraf": "^3.0.0", | ||
"tape": "^5.0.0", | ||
"remark-stringify": "^11.0.0", | ||
"retext-english": "^5.0.0", | ||
"retext-stringify": "^4.0.0", | ||
"type-coverage": "^2.0.0", | ||
"typescript": "^4.0.0", | ||
"xo": "^0.45.0" | ||
"typescript": "^5.0.0", | ||
"xo": "^0.56.0" | ||
}, | ||
"scripts": { | ||
"build": "rimraf \"lib/**/*.d.ts\" \"*.d.ts\" && tsc && type-coverage", | ||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", | ||
"build": "tsc --build --clean && tsc --build && type-coverage", | ||
"format": "remark . --frail --output --quiet && prettier . --log-level warn --write && xo --fix", | ||
"prepack": "npm run build && npm run format", | ||
"test": "npm run build && npm run format && npm run test-coverage", | ||
"test-api": "node --conditions development test.js", | ||
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api", | ||
"test": "npm run build && npm run format && npm run test-coverage" | ||
"test-coverage": "c8 --100 --reporter lcov npm run test-api" | ||
}, | ||
"prettier": { | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"bracketSpacing": false, | ||
"singleQuote": true, | ||
"bracketSpacing": false, | ||
"semi": false, | ||
"trailingComma": "none" | ||
"tabWidth": 2, | ||
"trailingComma": "none", | ||
"useTabs": false | ||
}, | ||
"xo": { | ||
"prettier": true | ||
}, | ||
"remarkConfig": { | ||
"plugins": [ | ||
"preset-wooorm" | ||
"remark-preset-wooorm" | ||
] | ||
@@ -87,10 +85,8 @@ }, | ||
"detail": true, | ||
"strict": true, | ||
"ignoreCatch": true, | ||
"#": "needed `any`s", | ||
"ignoreFiles": [ | ||
"lib/index.d.ts", | ||
"lib/index.js" | ||
] | ||
"strict": true | ||
}, | ||
"xo": { | ||
"prettier": true | ||
} | ||
} |
232
readme.md
@@ -21,4 +21,3 @@ # remark-retext | ||
* [`unified().use(remarkRetext, destination[, options])`](#unifieduseremarkretext-destination-options) | ||
* [Examples](#examples) | ||
* [Example: mutate mode](#example-mutate-mode) | ||
* [`Options`](#options) | ||
* [Types](#types) | ||
@@ -35,10 +34,2 @@ * [Compatibility](#compatibility) | ||
**unified** is a project that transforms content with abstract syntax trees | ||
(ASTs). | ||
**remark** adds support for markdown to unified. | ||
**retext** adds support for natural language to unified. | ||
**mdast** is the markdown AST that remark uses. | ||
**nlcst** is the natural language AST that retext uses. | ||
This is a remark plugin that transforms mdast into nlcst to support retext. | ||
## When should I use this? | ||
@@ -53,9 +44,14 @@ | ||
This plugin is unfortunately not able to apply changes by retext plugins (such | ||
This plugin is not able to apply changes by retext plugins (such | ||
as done by `retext-smartypants`) to the markdown content. | ||
This plugin is built on [`mdast-util-to-nlcst`][mdast-util-to-nlcst], which does | ||
the work on syntax trees. | ||
remark focusses on making it easier to transform content by abstracting such | ||
internals away. | ||
## Install | ||
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). | ||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]: | ||
This package is [ESM only][esm]. | ||
In Node.js (version 16+), install with [npm][]: | ||
@@ -66,13 +62,13 @@ ```sh | ||
In Deno with [Skypack][]: | ||
In Deno with [`esm.sh`][esmsh]: | ||
```js | ||
import remarkRetext from 'https://cdn.skypack.dev/remark-retext@5?dts' | ||
import remarkRetext from 'https://esm.sh/remark-retext@6' | ||
``` | ||
In browsers with [Skypack][]: | ||
In browsers with [`esm.sh`][esmsh]: | ||
```html | ||
<script type="module"> | ||
import remarkRetext from 'https://cdn.skypack.dev/remark-retext@5?min' | ||
import remarkRetext from 'https://esm.sh/remark-retext@6?bundle' | ||
</script> | ||
@@ -83,3 +79,3 @@ ``` | ||
Say we have the following file, `example.md`: | ||
Say we have the following file `example.md`: | ||
@@ -90,32 +86,28 @@ ```markdown | ||
And our script, `example.js`, looks as follows: | ||
…and a module `example.js`: | ||
```js | ||
import {read} from 'to-vfile' | ||
import {reporter} from 'vfile-reporter' | ||
import {unified} from 'unified' | ||
import remarkParse from 'remark-parse' | ||
import remarkRetext from 'remark-retext' | ||
import remarkStringify from 'remark-stringify' | ||
import remarkRetext from 'remark-retext' | ||
import retextEnglish from 'retext-english' | ||
import retextEquality from 'retext-equality' | ||
import {read} from 'to-vfile' | ||
import {unified} from 'unified' | ||
import {reporter} from 'vfile-reporter' | ||
main() | ||
const file = await unified() | ||
.use(remarkParse) | ||
.use(remarkRetext, unified().use(retextEnglish).use(retextEquality)) | ||
.use(remarkStringify) | ||
.process(await read('example.md')) | ||
async function main() { | ||
const file = await unified() | ||
.use(remarkParse) | ||
.use(remarkRetext, unified().use(retextEnglish).use(retextEquality)) | ||
.use(remarkStringify) | ||
.process(await read('example.md')) | ||
console.error(reporter(file)) | ||
} | ||
console.error(reporter(file)) | ||
``` | ||
Now, running `node example` yields: | ||
…then running `node example.js` yields: | ||
```text | ||
example.md | ||
1:10-1:14 warning `guys` may be insensitive, use `people`, `persons`, `folks` instead gals-man retext-equality | ||
1:10-1:14 warning Unexpected potentially insensitive use of `guys`, in somes cases `people`, `persons`, `folks` may be better gals-man retext-equality | ||
@@ -128,98 +120,58 @@ ⚠ 1 warning | ||
This package exports no identifiers. | ||
The default export is `remarkRetext`. | ||
The default export is [`remarkRetext`][api-remark-retext]. | ||
### `unified().use(remarkRetext, destination[, options])` | ||
**[remark][]** plugin to support **[retext][]**. | ||
Bridge or mutate to retext. | ||
##### `destination` | ||
###### Parameters | ||
`destination` is either a parser or a processor. | ||
* `destination` ([`Parser`][unified-parser] or | ||
[`Processor`][unified-processor]) | ||
— configuration (required) | ||
* If a destination [processor][] is given, runs the plugins attached to it | ||
with the new nlcst tree ([*bridge mode*][bridge]). | ||
This given processor must have a parser attached (this can be done by using | ||
the plugin `retext-english` or similar) and should use other retext plugins | ||
* If a parser is given, runs further plugins attached to the same processor | ||
with the new tree (*mutate mode*). | ||
Such parsers are exported by packages like `retext-english` as `Parser`. | ||
You should use other retext plugins after `remark-retext`. | ||
###### Returns | ||
##### `options` | ||
Transform ([`Transformer`][unified-transformer]). | ||
Configuration (`Object`, optional). | ||
###### Notes | ||
###### `options.ignore` | ||
* if a [processor][unified-processor] is given, uses its parser to create a | ||
new nlcst tree, then runs the plugins attached to with that | ||
(*[bridge mode][unified-mode]*); you can add a parser to processor for | ||
example with `retext-english`; other plugins used on the processor should | ||
be retext plugins | ||
* if a [parser][unified-parser] is given, uses it to create a new nlcst tree, | ||
and returns it (*[mutate mode][unified-mode]*); you can get a parser by | ||
importing `Parser` from `retext-english` for example; other plugins used | ||
after `remarkRetext` should be retext plugins | ||
List of [mdast][] node types to ignore (`Array.<string>`). | ||
The types `'table'`, `'tableRow'`, and `'tableCell'` are always ignored. | ||
### `Options` | ||
###### `options.source` | ||
Configuration (TypeScript type). | ||
List of [mdast][] node types to mark as [nlcst][] source nodes | ||
(`Array.<string>`). | ||
`'inlineCode'` is always marked as source. | ||
###### Fields | ||
## Examples | ||
* `options.ignore` (`Array<string>`, optional) | ||
— list of [mdast][] node types to ignore; | ||
the types `'table'`, `'tableRow'`, and `'tableCell'` are always ignored | ||
* `options.source` (`Array<string>`, optional) | ||
— list of [mdast][] node types to mark as [nlcst][] source nodes; | ||
the type `'inlineCode'` is always marked as source | ||
## Example: mutate mode | ||
The previous example was using *bridge* mode: the markdown AST remained for | ||
other plugins after `remark-retext`. | ||
This example uses *mutate* mode: the markdown AST is discarded and the natural | ||
language AST. | ||
This is not very useful: this is not a good way to get the plain text version | ||
of a markdown document. | ||
```js | ||
import {read} from 'to-vfile' | ||
import {reporter} from 'vfile-reporter' | ||
import {unified} from 'unified' | ||
import remarkParse from 'remark-parse' | ||
import remarkRetext from 'remark-retext' | ||
import {Parser} from 'retext-english' | ||
import retextEquality from 'retext-equality' | ||
import retextStringify from 'retext-stringify' | ||
main() | ||
async function main() { | ||
const file = await unified() | ||
.use(remarkParse) | ||
.use(remarkRetext, Parser) | ||
.use(retextEquality) | ||
.use(retextStringify) | ||
.process(await read('example.md')) | ||
console.error(reporter(file)) | ||
console.log(String(file)) | ||
} | ||
``` | ||
…yields: | ||
```txt | ||
example.md | ||
1:10-1:14 warning `guys` may be insensitive, use `people`, `persons`, `folks` instead gals-man retext-equality | ||
⚠ 1 warning | ||
``` | ||
```txt | ||
Hello guys! | ||
``` | ||
## Types | ||
This package is fully typed with [TypeScript][]. | ||
It exports an `Options` type, which specifies the interface of the accepted | ||
options. | ||
It exports the additional type [`Options`][api-options]. | ||
## Compatibility | ||
Projects maintained by the unified collective are compatible with all maintained | ||
Projects maintained by the unified collective are compatible with maintained | ||
versions of Node.js. | ||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+. | ||
Our projects sometimes work with older versions, but this is not guaranteed. | ||
When we cut a new major release, we drop support for unmaintained versions of | ||
Node. | ||
This means we try to keep the current release line, `remark-retext@^6`, | ||
compatible with Node.js 16. | ||
This plugin works with `unified` version 6+, `remark` version 3+, and `retext` | ||
@@ -230,4 +182,4 @@ version 7+. | ||
Use of `remark-retext` does not involve [**rehype**][rehype] ([**hast**][hast]) | ||
or user content so there are no openings for [cross-site scripting (XSS)][xss] | ||
Use of `remark-retext` does not involve **[rehype][]** (**[hast][]**) or user | ||
content so there are no openings for [cross-site scripting (XSS)][wiki-xss] | ||
attacks. | ||
@@ -238,9 +190,9 @@ | ||
* [`rehype-retext`](https://github.com/rehypejs/rehype-retext) | ||
— Transform HTML ([hast][]) to natural language ([nlcst][]) | ||
— transform HTML ([hast][]) to natural language ([nlcst][]) | ||
* [`remark-rehype`](https://github.com/remarkjs/remark-rehype) | ||
— Transform Markdown ([mdast][]) to HTML ([hast][]) | ||
— transform Markdown ([mdast][]) to HTML ([hast][]) | ||
* [`rehype-remark`](https://github.com/rehypejs/rehype-remark) | ||
— Transform HTML ([hast][]) to Markdown ([mdast][]) | ||
* [`mdast-util-to-nlcst`][to-nlcst] | ||
— Underlying algorithm | ||
— transform HTML ([hast][]) to Markdown ([mdast][]) | ||
* [`mdast-util-to-nlcst`][mdast-util-to-nlcst] | ||
— underlying algorithm | ||
@@ -275,5 +227,5 @@ ## Contribute | ||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-retext.svg | ||
[size-badge]: https://img.shields.io/bundlejs/size/remark-retext | ||
[size]: https://bundlephobia.com/result?p=remark-retext | ||
[size]: https://bundlejs.com/?q=remark-retext | ||
@@ -292,11 +244,13 @@ [sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg | ||
[skypack]: https://www.skypack.dev | ||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c | ||
[esmsh]: https://esm.sh | ||
[health]: https://github.com/remarkjs/.github | ||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md | ||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md | ||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md | ||
[support]: https://github.com/remarkjs/.github/blob/main/support.md | ||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md | ||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md | ||
@@ -307,2 +261,12 @@ [license]: license | ||
[hast]: https://github.com/syntax-tree/hast | ||
[mdast]: https://github.com/syntax-tree/mdast | ||
[mdast-util-to-nlcst]: https://github.com/syntax-tree/mdast-util-to-nlcst | ||
[nlcst]: https://github.com/syntax-tree/nlcst | ||
[rehype]: https://github.com/rehypejs/rehype | ||
[remark]: https://github.com/remarkjs/remark | ||
@@ -312,24 +276,22 @@ | ||
[unified]: https://github.com/unifiedjs/unified | ||
[retext-indefinite-article]: https://github.com/retextjs/retext-indefinite-article | ||
[processor]: https://github.com/unifiedjs/unified#processor | ||
[retext-readability]: https://github.com/retextjs/retext-readability | ||
[bridge]: https://github.com/unifiedjs/unified#processing-between-syntaxes | ||
[typescript]: https://www.typescriptlang.org | ||
[mdast]: https://github.com/syntax-tree/mdast | ||
[unified]: https://github.com/unifiedjs/unified | ||
[nlcst]: https://github.com/syntax-tree/nlcst | ||
[unified-mode]: https://github.com/unifiedjs/unified#processing-between-syntaxes | ||
[hast]: https://github.com/syntax-tree/hast | ||
[unified-processor]: https://github.com/unifiedjs/unified#processor | ||
[to-nlcst]: https://github.com/syntax-tree/mdast-util-to-nlcst | ||
[unified-parser]: https://github.com/unifiedjs/unified#parser | ||
[typescript]: https://www.typescriptlang.org | ||
[unified-transformer]: https://github.com/unifiedjs/unified#transformer | ||
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting | ||
[wiki-xss]: https://en.wikipedia.org/wiki/Cross-site_scripting | ||
[rehype]: https://github.com/rehypejs/rehype | ||
[api-options]: #options | ||
[retext-indefinite-article]: https://github.com/retextjs/retext-indefinite-article | ||
[retext-readability]: https://github.com/retextjs/retext-readability | ||
[api-remark-retext]: #unifieduseremarkretext-destination-options |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
18439
13
209
6
285
+ Added@types/nlcst@^2.0.0
+ Addedparse-latin@^7.0.0
+ Addedvfile@^6.0.0
+ Added@types/mdast@4.0.4(transitive)
+ Added@types/nlcst@2.0.3(transitive)
+ Added@types/unist@3.0.3(transitive)
+ Addedarray-iterate@2.0.1(transitive)
+ Addeddequal@2.0.3(transitive)
+ Addeddevlop@1.1.0(transitive)
+ Addedmdast-util-to-nlcst@7.0.1(transitive)
+ Addednlcst-to-string@4.0.0(transitive)
+ Addedparse-latin@7.0.0(transitive)
+ Addedunified@11.0.5(transitive)
+ Addedunist-util-modify-children@4.0.0(transitive)
+ Addedunist-util-position@5.0.0(transitive)
+ Addedunist-util-stringify-position@4.0.0(transitive)
+ Addedunist-util-visit-children@3.0.0(transitive)
+ Addedvfile@6.0.3(transitive)
+ Addedvfile-location@5.0.3(transitive)
+ Addedvfile-message@4.0.2(transitive)
- Removed@types/unist@^2.0.0
- Removed@types/mdast@3.0.15(transitive)
- Removed@types/nlcst@1.0.4(transitive)
- Removed@types/unist@2.0.11(transitive)
- Removedis-buffer@2.0.5(transitive)
- Removedmdast-util-to-nlcst@5.2.1(transitive)
- Removednlcst-to-string@3.1.1(transitive)
- Removedunified@10.1.2(transitive)
- Removedunist-util-position@4.0.4(transitive)
- Removedunist-util-stringify-position@3.0.3(transitive)
- Removedvfile@5.3.7(transitive)
- Removedvfile-location@4.1.0(transitive)
- Removedvfile-message@3.1.4(transitive)
Updated@types/mdast@^4.0.0
Updatedmdast-util-to-nlcst@^7.0.0
Updatedunified@^11.0.0