{"name":"rehype-katex","version":"1.0.0","description":"KaTeX transform plugin for rehype","main":"index.js","repository":{"type":"git","url":"git+https://github.com/Rokt33r/remark-math.git"},"keywords":["markdown","remark","math","katex","latex","tex"],"author":{"name":"Junyoung Choi","email":"fluke8259@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/Rokt33r/remark-math/issues"},"homepage":"https://github.com/Rokt33r/remark-math#readme","peerDependencies":{"remark-math":">=0.2.0"},"dependencies":{"katex":"^0.7.1","rehype-parse":"^3.0.0","unified":"^6.1.1","unist-util-position":"^3.0.0","unist-util-visit":"^1.1.1"},"files":["index.js"],"_id":"rehype-katex@1.0.0","scripts":{},"_shasum":"c2984ed59bb95d0a9fbce2001a21dc11ade2ad7e","_from":".","_npmVersion":"4.1.1","_nodeVersion":"6.9.2","_npmUser":{"name":"rokt33r","email":"fluke8259@gmail.com"},"dist":{"shasum":"c2984ed59bb95d0a9fbce2001a21dc11ade2ad7e","tarball":"http://registry-npm.ywwl.com/rehype-katex/download/rehype-katex-1.0.0.tgz","integrity":"sha512-NeNszGnb5rRLfAdheJeO3J5DnpveelhJe9b+jbSNhTp/HmWtqNxcWs6OCR7hQExst9ZvxQSc+wyvyO52ektj/Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDQvkIgu3rpcUcl9p6DquFUBGlihc7yxEOfsQhhLk/McQIhAOsfy4V2KHGhbh5GfJtHmZAsEtGY8pUHnScKaVwzdMVQ"}],"size":1777,"noattachment":false,"key":"/rehype-katex/-/rehype-katex-1.0.0.tgz"},"maintainers":[{"name":"rokt33r","email":"fluke8259@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/rehype-katex-1.0.0.tgz_1491481476821_0.8744800514541566"},"directories":{},"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":1491481478649,"_cnpm_publish_time":1491481478649,"dist-tags":{"latest":"7.0.1"}}