{"_id":"@deancureton/rehype-katex","name":"@deancureton/rehype-katex","dist-tags":{"latest":"7.0.1"},"versions":{"7.0.1":{"author":{"name":"Junyoung Choi","email":"fluke8259@gmail.com","url":"https://rokt33r.github.io"},"bugs":{"url":"https://github.com/deancureton/remark-math/issues"},"contributors":[{"name":"Junyoung Choi","email":"fluke8259@gmail.com","url":"https://rokt33r.github.io"},{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},{"name":"Dean Cureton","email":"deancureton73@gmail.com","url":"https://deancureton.com"}],"dependencies":{"@types/hast":"^3.0.0","@types/katex":"^0.16.0","hast-util-from-html-isomorphic":"^2.0.0","hast-util-to-text":"^4.0.0","katex":"^0.16.0","unist-util-visit-parents":"^6.0.0","vfile":"^6.0.0"},"description":"rehype plugin to transform inline and block math with KaTeX","exports":"./index.js","keywords":["hast","html","katex","latex","markdown","math","mdast","plugin","rehype","rehype-plugin","remark","tex","unified"],"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"license":"MIT","name":"@deancureton/rehype-katex","repository":{"type":"git","url":"git+https://github.com/deancureton/remark-math.git#main"},"scripts":{"test-api":"node --conditions development test.js","test":"npm run build && npm run test-api"},"sideEffects":false,"type":"module","version":"7.0.1","xo":{"prettier":true,"rules":{"unicorn/prefer-at":"off"}},"_id":"@deancureton/rehype-katex@7.0.1","gitHead":"e3328a54032af436303af3c3f45b8beff3a2cf6f","types":"./index.d.ts","homepage":"https://github.com/deancureton/remark-math/tree/main#readme","_nodeVersion":"23.3.0","_npmVersion":"11.5.2","dist":{"integrity":"sha512-iMOjoAR35WY2s76RXezbqLbsk39W62e67eijaY6bHYjubTGZj5MPtL+v9/q3JFrD7LhC1Jakh1j6MduFVHBqnQ==","shasum":"8ae75ef98e06538ef1ae83fcec9444ed5e8f4869","tarball":"https://registry.npmjs.org/@deancureton/rehype-katex/-/rehype-katex-7.0.1.tgz","fileCount":8,"unpackedSize":16748,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIH2Nxpkj22Bt4zlHW0sl+GuU8zZtyI7wSoB7b5CfJ45/AiEA8JmNadmThS1Kq7s4760sVLRZJEMJoMFp8XcV69ZCIa8="}]},"_npmUser":{"name":"deancureton","email":"deancureton73@gmail.com"},"directories":{},"maintainers":[{"name":"deancureton","email":"deancureton73@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rehype-katex_7.0.1_1755904087683_0.3541745917925352"},"_hasShrinkwrap":false}},"time":{"created":"2025-08-22T23:08:07.598Z","7.0.1":"2025-08-22T23:08:07.879Z","modified":"2025-08-22T23:08:08.116Z"},"maintainers":[{"name":"deancureton","email":"deancureton73@gmail.com"}],"description":"rehype plugin to transform inline and block math with KaTeX","homepage":"https://github.com/deancureton/remark-math/tree/main#readme","keywords":["hast","html","katex","latex","markdown","math","mdast","plugin","rehype","rehype-plugin","remark","tex","unified"],"repository":{"type":"git","url":"git+https://github.com/deancureton/remark-math.git#main"},"contributors":[{"name":"Junyoung Choi","email":"fluke8259@gmail.com","url":"https://rokt33r.github.io"},{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},{"name":"Dean Cureton","email":"deancureton73@gmail.com","url":"https://deancureton.com"}],"author":{"name":"Junyoung Choi","email":"fluke8259@gmail.com","url":"https://rokt33r.github.io"},"bugs":{"url":"https://github.com/deancureton/remark-math/issues"},"license":"MIT","readme":"# rehype-katex\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 render elements with a `language-math` class with\n[KaTeX][].\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(rehypeKatex[, options])`](#unifieduserehypekatex-options)\n  * [`Options`](#options)\n* [Markdown](#markdown)\n* [HTML](#html)\n* [CSS](#css)\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 render math.\nYou can add classes to HTML elements, use fenced code in markdown, or combine\nwith [`remark-math`][remark-math] for a `$C$` syntax extension.\n\n## When should I use this?\n\nThis project is useful as it renders math with KaTeX at compile time, which\nmeans that there is no client side JavaScript needed.\n\nA different plugin, [`rehype-mathjax`][rehype-mathjax], does the same but with\n[MathJax][].\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install rehype-katex\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport rehypeKatex from 'https://esm.sh/rehype-katex@7'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import rehypeKatex from 'https://esm.sh/rehype-katex@7?bundle'\n</script>\n```\n\n## Use\n\nSay our document `input.html` contains:\n\n```html\n<p>\n  Lift(<code class=\"language-math\">L</code>) can be determined by Lift Coefficient\n  (<code class=\"language-math\">C_L</code>) like the following equation.\n</p>\n<pre><code class=\"language-math\">\n  L = \\frac{1}{2} \\rho v^2 S C_L\n</code></pre>\n```\n\n…and our module `example.js` contains:\n\n```js\nimport rehypeDocument from 'rehype-document'\nimport rehypeKatex from 'rehype-katex'\nimport rehypeParse from 'rehype-parse'\nimport rehypeStringify from 'rehype-stringify'\nimport {read, write} from 'to-vfile'\nimport {unified} from 'unified'\n\nconst file = await unified()\n  .use(rehypeParse, {fragment: true})\n  .use(rehypeDocument, {\n    // Get the latest one from: <https://katex.org/docs/browser>.\n    css: 'https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css'\n  })\n  .use(rehypeKatex)\n  .use(rehypeStringify)\n  .process(await read('input.html'))\n\nfile.basename = 'output.html'\nawait write(file)\n```\n\n…then running `node example.js` creates an `output.html` with:\n\n```html\n<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>input</title>\n<meta content=\"width=device-width, initial-scale=1\" name=\"viewport\">\n<link href=\"https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css\" rel=\"stylesheet\">\n</head>\n<body>\n<p>\n  Lift(<span class=\"katex\"><!--…--></span>) can be determined by Lift Coefficient\n  (<span class=\"katex\"><!--…--></span>) like the following equation.\n</p>\n<span class=\"katex-display\"><!--…--></span>\n</body>\n</html>\n```\n\n…open `output.html` in a browser to see the rendered math.\n\n## API\n\nThis package exports no identifiers.\nThe default export is [`rehypeKatex`][api-rehype-katex].\n\n### `unified().use(rehypeKatex[, options])`\n\nRender elements with a `language-math` (or `math-display`, `math-inline`)\nclass with [KaTeX][].\n\n###### Parameters\n\n* `options` ([`Options`][api-options])\n  — configuration\n\n###### Returns\n\nTransform ([`Transformer`][unified-transformer]).\n\n### `Options`\n\nConfiguration (TypeScript type).\n\n###### Type\n\n```ts\nimport {KatexOptions} from 'katex'\n\ntype Options = Omit<KatexOptions, 'displayMode' | 'throwOnError'>\n```\n\nSee [*Options* on `katex.org`][katex-options] for more info.\n\n## Markdown\n\nThis plugin supports the syntax extension enabled by\n[`remark-math`][remark-math].\nIt also supports math generated by using fenced code:\n\n````markdown\n```math\nC_L\n```\n````\n\n## HTML\n\nThe content of any element with a `language-math`, `math-inline`, or\n`math-display` class is transformed.\nThe elements are replaced by what KaTeX renders.\nEither a `math-display` class or using `<pre><code class=\"language-math\">` will\nresult in “display” math: math that is a centered block on its own line.\n\n## CSS\n\nThe HTML produced by KaTeX requires CSS to render correctly.\nYou should use `katex.css` somewhere on the page where the math is shown to\nstyle it properly.\nAt the time of writing, the last version is:\n\n```html\n<!-- Get the latest one from: https://katex.org/docs/browser -->\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css\">\n```\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional type [`Options`][api-options].\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-katex@7`,\ncompatible with Node.js 16.\n\nThis plugin works with unified version 6+ and rehype version 4+.\n\n## Security\n\nAssuming you trust KaTeX, using `rehype-katex` is safe.\nA vulnerability in it could open you to a\n[cross-site scripting (XSS)][wiki-xss] attack.\nBe wary of user input and use [`rehype-sanitize`][rehype-sanitize].\n\nWhen you don’t trust user content but do trust KaTeX, run `rehype-katex`\n*after* `rehype-sanitize`:\n\n```js\nimport rehypeKatex from 'rehype-katex'\nimport rehypeSanitize, {defaultSchema} from 'rehype-sanitize'\nimport rehypeStringify from 'rehype-stringify'\nimport remarkMath from 'remark-math'\nimport remarkParse from 'remark-parse'\nimport remarkRehype from 'remark-rehype'\nimport {unified} from 'unified'\n\nconst file = await unified()\n  .use(remarkParse)\n  .use(remarkMath)\n  .use(remarkRehype)\n  .use(rehypeSanitize, {\n    ...defaultSchema,\n    attributes: {\n      ...defaultSchema.attributes,\n      // The `language-*` regex is allowed by default.\n      code: [['className', /^language-./, 'math-inline', 'math-display']]\n    }\n  })\n  .use(rehypeKatex)\n  .use(rehypeStringify)\n  .process('$C$')\n\nconsole.log(String(file))\n```\n\n## Related\n\n* [`rehype-mathjax`][rehype-mathjax]\n  — same but with MathJax\n* [`rehype-highlight`](https://github.com/rehypejs/rehype-highlight)\n  — highlight code blocks\n* [`rehype-autolink-headings`](https://github.com/rehypejs/rehype-autolink-headings)\n  — add links to headings\n* [`rehype-sanitize`][rehype-sanitize]\n  — sanitize HTML\n* [`rehype-document`](https://github.com/rehypejs/rehype-document)\n  — wrap a document around the tree\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`remarkjs/.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] © [Junyoung Choi][author]\n\n<!-- Definitions -->\n\n[api-options]: #options\n\n[api-rehype-katex]: #unifieduserehypekatex-options\n\n[author]: https://rokt33r.github.io\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[build]: https://github.com/remarkjs/remark-math/actions\n\n[build-badge]: https://github.com/remarkjs/remark-math/workflows/main/badge.svg\n\n[chat]: https://github.com/remarkjs/remark/discussions\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md\n\n[collective]: https://opencollective.com/unified\n\n[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md\n\n[coverage]: https://codecov.io/github/remarkjs/remark-math\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-math.svg\n\n[downloads]: https://www.npmjs.com/package/rehype-katex\n\n[downloads-badge]: https://img.shields.io/npm/dm/rehype-katex.svg\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[health]: https://github.com/remarkjs/.github\n\n[katex]: https://github.com/Khan/KaTeX\n\n[katex-options]: https://katex.org/docs/options.html\n\n[license]: https://github.com/remarkjs/remark-math/blob/main/license\n\n[mathjax]: https://www.mathjax.org\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[rehype]: https://github.com/rehypejs/rehype\n\n[rehype-mathjax]: ../rehype-mathjax/\n\n[rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize\n\n[remark-math]: ../remark-math/\n\n[size]: https://bundlejs.com/?q=rehype-katex\n\n[size-badge]: https://img.shields.io/bundlejs/size/rehype-katex\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[support]: https://github.com/remarkjs/.github/blob/main/support.md\n\n[typescript]: https://www.typescriptlang.org\n\n[unified]: https://github.com/unifiedjs/unified\n\n[unified-transformer]: https://github.com/unifiedjs/unified#transformer\n\n[wiki-xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n","readmeFilename":"readme.md","_rev":"1-073c8cdb44a028ccc16bce5b44cfac8e"}