{"name":"rehype-retext","version":"5.0.0","description":"rehype plugin to transform to retext","license":"MIT","keywords":["hast","html","langauge","natural","nlcst","rehype","rehype-plugin","retext","retext-plugin","unified"],"repository":{"type":"git","url":"git+https://github.com/rehypejs/rehype-retext.git"},"bugs":{"url":"https://github.com/rehypejs/rehype-retext/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"sideEffects":false,"type":"module","exports":"./index.js","dependencies":{"@types/hast":"^3.0.0","@types/nlcst":"^2.0.0","hast-util-to-nlcst":"^4.0.0","parse-latin":"^7.0.0","unified":"^11.0.0","vfile":"^6.0.0"},"devDependencies":{"@types/node":"^20.0.0","c8":"^10.0.0","parse-english":"^7.0.0","prettier":"^3.0.0","rehype-parse":"^9.0.0","rehype-stringify":"^10.0.0","remark-cli":"^12.0.0","remark-preset-wooorm":"^10.0.0","retext-english":"^5.0.0","retext-stringify":"^4.0.0","type-coverage":"^2.0.0","typescript":"^5.5.1-rc","xo":"^0.58.0"},"scripts":{"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 --100 --check-coverage --reporter lcov npm run test-api"},"prettier":{"bracketSpacing":false,"singleQuote":true,"semi":false,"tabWidth":2,"trailingComma":"none","useTabs":false},"remarkConfig":{"plugins":["remark-preset-wooorm"]},"typeCoverage":{"atLeast":100,"detail":true,"ignoreCatch":true,"strict":true},"xo":{"prettier":true},"_id":"rehype-retext@5.0.0","gitHead":"5ed21b133d1b1783837a039764fdf6acb7bf8280","types":"./index.d.ts","homepage":"https://github.com/rehypejs/rehype-retext#readme","_nodeVersion":"22.0.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-amCBMrCItZzu2tLIfL+m0S8mE6+nwD+H88hesbxCgZ9AdMZ42aGPqunMh+bbkb/v1kY3bwppSnfPMDmxIz42Nw==","shasum":"93278df90428b5ee523b17da5bd6b8d167ddfb6a","tarball":"http://registry-npm.ywwl.com/rehype-retext/download/rehype-retext-5.0.0.tgz","fileCount":9,"unpackedSize":18183,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCdjchNELTMpD1LP5b01w4eVFs2ZApvuJ0RznJJIV5bPQIgan3dAeOxWBC2YupGhRx9APxYDuEzY3iC2292IwCpEe4="}],"size":6035,"noattachment":false,"key":"/rehype-retext/-/rehype-retext-5.0.0.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"remcohaszing","email":"remcohaszing@gmail.com"},{"name":"wooorm","email":"tituswormer@gmail.com"},{"name":"kmck","email":"keith@mcknig.ht"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rehype-retext_5.0.0_1718628019989_0.7158254297600823"},"_hasShrinkwrap":false,"readme":"# rehype-retext\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n**[rehype][]** plugin to support **[retext][]**.\n\n## Contents\n\n* [What is this?](#what-is-this)\n* [When should I use this?](#when-should-i-use-this)\n* [Install](#install)\n* [Use](#use)\n* [API](#api)\n  * [`unified().use(rehypeRetext, options)`](#unifieduserehyperetext-options)\n* [Types](#types)\n* [Compatibility](#compatibility)\n* [Security](#security)\n* [Related](#related)\n* [Contribute](#contribute)\n* [License](#license)\n\n## What is this?\n\nThis package is a [unified][] ([rehype][]) plugin to support [retext][].\n\n**unified** is a project that transforms content with abstract syntax trees\n(ASTs).\n**rehype** adds support for HTML to unified.\n**retext** adds support for natural language to unified.\n**hast** is the HTML AST that rehype uses.\n**nlcst** is the natural language AST that retext uses.\nThis is a rehype plugin that transforms hast into nlcst to support retext.\n\n## When should I use this?\n\nThis project is useful if you want to check natural language in HTML.\nThe retext ecosystem has many useful plugins to check prose, such as\n[`retext-indefinite-article`][retext-indefinite-article] which checks that `a`\nand `an` are used correctly, or [`retext-readability`][retext-readability] which\nchecks that sentences are not too complex.\nThis plugins lets you use them on HTML documents.\n\nThis plugin is not able to apply changes by retext plugins (such\nas done by `retext-smartypants`) to the HTML content.\n\nThis plugin is built on [`hast-util-to-nlcst`][hast-util-to-nlcst], which does\nthe work on syntax trees.\nrehype focusses on making it easier to transform content by abstracting such\ninternals away.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install rehype-retext\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport rehypeRetext from 'https://esm.sh/rehype-retext@5'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import rehypeRetext from 'https://esm.sh/rehype-retext@5?bundle'\n</script>\n```\n\n## Use\n\nSay we have the following file `example.html`:\n\n```html\n<!doctype html>\n<meta charset=utf8>\n<title>Hello!</title>\n<article>\n  A implicit sentence.\n  <h1>This and and that.</h1>\n</article>\n```\n\n…and our module `example.js` looks as follows:\n\n```js\nimport rehypeParse from 'rehype-parse'\nimport rehypePresetMinify from 'rehype-preset-minify'\nimport rehypeRetext from 'rehype-retext'\nimport rehypeStringify from 'rehype-stringify'\nimport retextEnglish from 'retext-english'\nimport retextIndefiniteArticle from 'retext-indefinite-article'\nimport retextRepeatedWords from 'retext-repeated-words'\nimport {read} from 'to-vfile'\nimport {unified} from 'unified'\nimport {reporter} from 'vfile-reporter'\n\nconst file = await unified()\n  .use(rehypeParse)\n  .use(\n    rehypeRetext,\n    unified()\n      .use(retextEnglish)\n      .use(retextIndefiniteArticle)\n      .use(retextRepeatedWords)\n  )\n  .use(rehypePresetMinify)\n  .use(rehypeStringify)\n  .process(await read('example.html'))\n\nconsole.error(reporter([file]))\nconsole.log(String(file))\n```\n\n…then running `node example.js` yields:\n\n```html\nexample.html\n5:3-5:4   warning Unexpected article `A` before `implicit`, expected `An` retext-indefinite-article retext-indefinite-article\n6:12-6:19 warning Unexpected repeated `and`, remove one occurrence        and                       retext-repeated-words\n\n⚠ 2 warnings\n```\n\n```html\n<!doctypehtml><meta charset=utf8><title>Hello!</title><article>A implicit sentence.<h1>This and and that.</h1></article>\n```\n\n## API\n\nThis package exports no identifiers.\nThe default export is [`rehypeRetext`][api-rehype-retext].\n\n### `unified().use(rehypeRetext, options)`\n\nBridge or mutate to retext.\n\n###### Parameters\n\n* `options` ([`Parser`][unified-parser] or [`Processor`][unified-processor])\n  — configuration (required)\n\n###### Returns\n\nTransform ([`Transformer`][unified-transformer]).\n\n###### Notes\n\n* if a [processor][unified-processor] is given, uses its parser to create a\n  new nlcst tree, then runs the plugins attached to with that\n  (*[bridge mode][unified-mode]*); you can add a parser to processor for\n  example with `retext-english`; other plugins used on the processor should\n  be retext plugins\n* if a [parser][unified-parser] is given, uses it to create a new nlcst tree,\n  and returns it (*[mutate mode][unified-mode]*); you can get a parser by\n  importing `Parser` from `retext-english` for example;  other plugins used\n  after `rehypeRetext` should be retext plugins\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports no additional types.\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line, `rehype-retext@5`,\ncompatible with Node.js 16.\n\nThis plugin works with `unified` version 6+, `rehype` version 4+, and `retext`\nversion 7+.\n\n## Security\n\n`rehype-retext` does not change the syntax tree so there are no openings for\n[cross-site scripting (XSS)][xss] attacks.\n\n## Related\n\n* [`rehype-remark`](https://github.com/rehypejs/rehype-remark)\n  — rehype plugin to turn HTML into markdown\n* [`remark-retext`](https://github.com/remarkjs/remark-retext)\n  — remark plugin to support retext\n* [`remark-rehype`](https://github.com/remarkjs/remark-rehype)\n  — remark plugin to turn markdown into HTML\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`rehypejs/.github`][health] for ways\nto get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n<!-- Definitions -->\n\n[build-badge]: https://github.com/rehypejs/rehype-retext/workflows/main/badge.svg\n\n[build]: https://github.com/rehypejs/rehype-retext/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype-retext.svg\n\n[coverage]: https://codecov.io/github/rehypejs/rehype-retext\n\n[downloads-badge]: https://img.shields.io/npm/dm/rehype-retext.svg\n\n[downloads]: https://www.npmjs.com/package/rehype-retext\n\n[size-badge]: https://img.shields.io/bundlejs/size/rehype-retext\n\n[size]: https://bundlejs.com/?q=rehype-retext\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/rehypejs/rehype/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[health]: https://github.com/rehypejs/.github\n\n[contributing]: https://github.com/rehypejs/.github/blob/main/contributing.md\n\n[support]: https://github.com/rehypejs/.github/blob/main/support.md\n\n[coc]: https://github.com/rehypejs/.github/blob/main/code-of-conduct.md\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[typescript]: https://www.typescriptlang.org\n\n[hast-util-to-nlcst]: https://github.com/syntax-tree/hast-util-to-nlcst\n\n[rehype]: https://github.com/rehypejs/rehype\n\n[retext]: https://github.com/retextjs/retext\n\n[retext-indefinite-article]: https://github.com/retextjs/retext-indefinite-article\n\n[retext-readability]: https://github.com/retextjs/retext-readability\n\n[unified]: https://github.com/unifiedjs/unified\n\n[unified-mode]: https://github.com/unifiedjs/unified#transforming-between-ecosystems\n\n[unified-parser]: https://github.com/unifiedjs/unified#parser\n\n[unified-processor]: https://github.com/unifiedjs/unified#processor\n\n[unified-transformer]: https://github.com/unifiedjs/unified#transformer\n\n[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n\n[api-rehype-retext]: #unifieduserehyperetext-options\n","publish_time":1718628020136,"_cnpm_publish_time":1718628020136,"dist-tags":{"latest":"5.0.1"}}