{"id":13783998,"url":"https://github.com/rehypejs/rehype-retext","last_synced_at":"2025-06-16T02:42:31.479Z","repository":{"id":45129647,"uuid":"69400025","full_name":"rehypejs/rehype-retext","owner":"rehypejs","description":"plugin to transform from HTML (rehype) to prose (retext)","archived":false,"fork":false,"pushed_at":"2025-04-02T14:00:57.000Z","size":119,"stargazers_count":18,"open_issues_count":0,"forks_count":2,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-07T09:54:37.805Z","etag":null,"topics":["hast","html","natural-language","nlcst","rehype","rehype-plugin","retext","retext-plugin"],"latest_commit_sha":null,"homepage":"https://unifiedjs.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rehypejs.png","metadata":{"funding":{"github":"unifiedjs","open_collective":"unified"},"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-09-27T21:25:47.000Z","updated_at":"2025-04-02T14:01:00.000Z","dependencies_parsed_at":"2024-01-18T18:08:34.134Z","dependency_job_id":"2a69cd7b-0ea2-440c-87f9-ef5592cbe97e","html_url":"https://github.com/rehypejs/rehype-retext","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype-retext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype-retext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype-retext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype-retext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rehypejs","download_url":"https://codeload.github.com/rehypejs/rehype-retext/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253621132,"owners_count":21937482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hast","html","natural-language","nlcst","rehype","rehype-plugin","retext","retext-plugin"],"created_at":"2024-08-03T19:00:34.189Z","updated_at":"2025-05-11T19:31:55.290Z","avatar_url":"https://github.com/rehypejs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":["Plugins"],"sub_categories":[],"readme":"# rehype-retext\n\n[![Build][badge-build-image]][badge-build-url]\n[![Coverage][badge-coverage-image]][badge-coverage-url]\n[![Downloads][badge-downloads-image]][badge-downloads-url]\n[![Size][badge-size-image]][badge-size-url]\n\n**[rehype][github-rehype]** plugin to support **[retext][github-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][github-unified] ([rehype][github-rehype])\nplugin to support [retext][github-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,\nsuch as\n[`retext-indefinite-article`][github-retext-indefinite-article]\nwhich checks that `a` and `an` are used correctly,\nor [`retext-readability`][github-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`][github-hast-util-to-nlcst],\nwhich does the 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][github-gist-esm].\nIn Node.js (version 16+),\ninstall with [npm][npmjs-install]:\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\u003cscript type=\"module\"\u003e\n  import rehypeRetext from 'https://esm.sh/rehype-retext@5?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\nSay we have the following file `example.html`:\n\n```html\n\u003c!doctype html\u003e\n\u003cmeta charset=utf8\u003e\n\u003ctitle\u003eHello!\u003c/title\u003e\n\u003carticle\u003e\n  A implicit sentence.\n  \u003ch1\u003eThis and and that.\u003c/h1\u003e\n\u003c/article\u003e\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\u003c!doctypehtml\u003e\u003cmeta charset=utf8\u003e\u003ctitle\u003eHello!\u003c/title\u003e\u003carticle\u003eA implicit sentence.\u003ch1\u003eThis and and that.\u003c/h1\u003e\u003c/article\u003e\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`\n  ([`Parser`][github-unified-parser] or\n  [`Processor`][github-unified-processor])\n  — configuration (required)\n\n###### Returns\n\nTransform ([`Transformer`][github-unified-transformer]).\n\n###### Notes\n\n* if a [processor][github-unified-processor] is given,\n  uses its parser to create a new nlcst tree,\n  then runs the plugins attached to with that\n  (*[bridge mode][github-unified-mode]*);\n  you can add a parser to processor for example with `retext-english`;\n  other plugins used on the processor should be retext plugins\n* if a [parser][github-unified-parser] is given,\n  uses it to create a new nlcst tree,\n  and returns it\n  (*[mutate mode][github-unified-mode]*);\n  you can get a parser by importing `Parser` from `parse-english` for example;\n  other plugins used 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,\nwe drop support for unmaintained versions of Node.\nThis means we try to keep the current release line,\n`rehype-retext@5`,\ncompatible with Node.js 16.\n\nThis plugin works with `unified` version 6+,\n`rehype` version 4+,\nand `retext` version 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)][wikipedia-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`][health-contributing] in [`rehypejs/.github`][health]\nfor ways to get started.\nSee [`support.md`][health-support] for ways to get help.\n\nThis project has a [code of conduct][health-coc].\nBy interacting with this repository,\norganization,\nor community you agree to abide by its terms.\n\n## License\n\n[MIT][file-license] © [Titus Wormer][wooorm]\n\n\u003c!-- Definitions --\u003e\n\n[api-rehype-retext]: #unifieduserehyperetext-options\n\n[badge-build-image]: https://github.com/rehypejs/rehype-retext/workflows/main/badge.svg\n\n[badge-build-url]: https://github.com/rehypejs/rehype-retext/actions\n\n[badge-coverage-image]: https://img.shields.io/codecov/c/github/rehypejs/rehype-retext.svg\n\n[badge-coverage-url]: https://codecov.io/github/rehypejs/rehype-retext\n\n[badge-downloads-image]: https://img.shields.io/npm/dm/rehype-retext.svg\n\n[badge-downloads-url]: https://www.npmjs.com/package/rehype-retext\n\n[badge-size-image]: https://img.shields.io/bundlejs/size/rehype-retext\n\n[badge-size-url]: https://bundlejs.com/?q=rehype-retext\n\n[esmsh]: https://esm.sh\n\n[file-license]: license\n\n[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[github-hast-util-to-nlcst]: https://github.com/syntax-tree/hast-util-to-nlcst\n\n[github-rehype]: https://github.com/rehypejs/rehype\n\n[github-retext]: https://github.com/retextjs/retext\n\n[github-retext-indefinite-article]: https://github.com/retextjs/retext-indefinite-article\n\n[github-retext-readability]: https://github.com/retextjs/retext-readability\n\n[github-unified]: https://github.com/unifiedjs/unified\n\n[github-unified-mode]: https://github.com/unifiedjs/unified#transforming-between-ecosystems\n\n[github-unified-parser]: https://github.com/unifiedjs/unified#parser\n\n[github-unified-processor]: https://github.com/unifiedjs/unified#processor\n\n[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer\n\n[health]: https://github.com/rehypejs/.github\n\n[health-coc]: https://github.com/rehypejs/.github/blob/main/code-of-conduct.md\n\n[health-contributing]: https://github.com/rehypejs/.github/blob/main/contributing.md\n\n[health-support]: https://github.com/rehypejs/.github/blob/main/support.md\n\n[npmjs-install]: https://docs.npmjs.com/cli/install\n\n[typescript]: https://www.typescriptlang.org\n\n[wikipedia-xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n\n[wooorm]: https://wooorm.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frehypejs%2Frehype-retext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frehypejs%2Frehype-retext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frehypejs%2Frehype-retext/lists"}