{"name":"rehype-katex","version":"6.0.3","description":"rehype plugin to transform inline and block math with KaTeX","license":"MIT","keywords":["unified","remark","rehype","rehype-plugin","plugin","mdast","markdown","hast","html","math","katex","latex","tex"],"repository":{"type":"git","url":"git+https://github.com/remarkjs/remark-math.git#main"},"bugs":{"url":"https://github.com/remarkjs/remark-math/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"Junyoung Choi","email":"fluke8259@gmail.com","url":"https://rokt33r.github.io"},"contributors":[{"name":"Junyoung Choi","email":"fluke8259@gmail.com","url":"https://rokt33r.github.io"},{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"sideEffects":false,"type":"module","main":"index.js","types":"index.d.ts","dependencies":{"@types/hast":"^2.0.0","@types/katex":"^0.14.0","hast-util-from-html-isomorphic":"^1.0.0","hast-util-to-text":"^3.1.0","katex":"^0.16.0","unist-util-visit":"^4.0.0"},"scripts":{"build":"rimraf \"*.d.ts\" && tsc && type-coverage","test-api":"node --conditions development test.js","test":"npm run build && npm run test-api"},"xo":false,"typeCoverage":{"atLeast":100,"detail":true,"strict":true,"ignoreCatch":true},"gitHead":"e18d024ce76f90bd6b89366091aa2a5dda771864","homepage":"https://github.com/remarkjs/remark-math/tree/main#readme","_id":"rehype-katex@6.0.3","_nodeVersion":"19.8.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-ByZlRwRUcWegNbF70CVRm2h/7xy7jQ3R9LaY4VVSvjnoVWwWVhNL60DiZsBpC5tSzYQOCvDbzncIpIjPZWodZA==","shasum":"83e5b929b0967978e9491c02117f55be3594d7e1","tarball":"http://registry-npm.ywwl.com/rehype-katex/download/rehype-katex-6.0.3.tgz","fileCount":4,"unpackedSize":13019,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQClRjz0HBQpxkbX/6Qip5Nrbp13lpTRzF/5W2QRANEtZwIgNbJRH6eZph1KrYeAi6JQJHLEIjIpEASwPE43WuYslt4="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkRS4IACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmobcA/+NLYatoflBPgoJlj+GG07Qsw/9EqWPSBxu9bSGvJqap0FD4ms\r\nTcOtuwHQ8Ye2gxUsrfIf+FHIB0ODSp8PHwoJB8ehlYDg9LBhkU/OQpwPj5j1\r\n347gVvHnTz0N8195VLj5vTwRzKW9CxNjHtgMu7uoL4HNkMNU9yrub35r5t/H\r\ndmHIBI7lZLoqd9CXhS2VGHVoLqL2GwO1oW9+4l7OsZLbFvUzUQAI6dcZW18T\r\nS40GneyxuLlSB6pBldShigEy0CNHZhq0I4hFlAXRaYvbPdzrI8wTcAH7ummZ\r\nryl6IAcVQTrRghv52gpwiAr41Jb2TfiyBitj1fxJM10CElY/354Je/azQMos\r\nsXDZ08iPyhPlsWZU4VlxnnxOzgMkfh2eAa0qkiuYC/xyU+BHYZm1bJ9LCRqU\r\n2nIAitpOt3j71W+hIcXwug+a4mx3duj50oPhc0z5as5n0/ghAi6tBVmHLxN2\r\ncT4NQtJqlCUm6lAmEy/OD5fqgJqZhuFy4am0ILGVLYNUCIMAkVLsRrilu+e7\r\nGpjTXofpL7t3SzHPZjK42Wvdao+ETIbDQqUJJQ6ggi7ljR063MTCvX9+s5Jc\r\nMsLDe8e50YUINwY1XZTvWGla4ZLOJdCT6jCHT7QDExwH9HDWa2kWzCVxoPcS\r\nxSxzTYUbVTXfLii4xvyqnoOQ81YbIXxhqeU=\r\n=PF6X\r\n-----END PGP SIGNATURE-----\r\n","size":4961,"noattachment":false,"key":"/rehype-katex/-/rehype-katex-6.0.3.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"johno","email":"johnotander@gmail.com"},{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rehype-katex_6.0.3_1682255368424_0.9082647710351475"},"_hasShrinkwrap":false,"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`](https://github.com/rehypejs/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[build-badge]: https://github.com/remarkjs/remark-math/workflows/main/badge.svg\n\n[build]: https://github.com/remarkjs/remark-math/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-math.svg\n\n[coverage]: https://codecov.io/github/remarkjs/remark-math\n\n[downloads-badge]: https://img.shields.io/npm/dm/rehype-katex.svg\n\n[downloads]: https://www.npmjs.com/package/rehype-katex\n\n[size-badge]: https://img.shields.io/bundlejs/size/rehype-katex\n\n[size]: https://bundlejs.com/?q=rehype-katex\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/remarkjs/remark/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/remarkjs/.github\n\n[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md\n\n[support]: https://github.com/remarkjs/.github/blob/main/support.md\n\n[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md\n\n[license]: https://github.com/remarkjs/remark-math/blob/main/license\n\n[author]: https://rokt33r.github.io\n\n[katex]: https://github.com/Khan/KaTeX\n\n[katex-options]: https://katex.org/docs/options.html\n\n[rehype]: https://github.com/rehypejs/rehype\n\n[rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize\n\n[unified]: https://github.com/unifiedjs/unified\n\n[unified-transformer]: https://github.com/unifiedjs/unified#transformer\n\n[typescript]: https://www.typescriptlang.org\n\n[wiki-xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n\n[mathjax]: https://www.mathjax.org\n\n[remark-math]: ../remark-math/\n\n[rehype-mathjax]: ../rehype-mathjax/\n\n[api-options]: #options\n\n[api-rehype-katex]: #unifieduserehypekatex-options\n","publish_time":1682255368620,"_cnpm_publish_time":1682255368620,"dist-tags":{"latest":"7.0.1"}}