Gathering detailed insights and metrics for rehype-katex
Gathering detailed insights and metrics for rehype-katex
Gathering detailed insights and metrics for rehype-katex
Gathering detailed insights and metrics for rehype-katex
rehype-katex-notranslate
Add the attribute translate="no" to the katex formula generated by rehype-katex to prevent the formulas from being recognized and translated by webpage translation tools.
rehype-katex-svelte
rehype plugin to transform .math-inline, .math-display with KaTeX to Svelte markup
rehype-mathjax
rehype plugin to transform inline and block math with MathJax
katex
Fast math typesetting for the web.
npm install rehype-katex
rehype-katex@7.0.1
Published on 19 Aug 2024
rehype-mathjax@6.0.0
Published on 21 Dec 2023
rehype-mathjax@5.0.0
Published on 19 Sept 2023
rehype-katex@7.0.0
Published on 19 Sept 2023
6.0.0
Published on 19 Sept 2023
rehype-mathjax@4.0.3
Published on 18 Jul 2023
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
382 Stars
272 Commits
57 Forks
9 Watching
1 Branches
29 Contributors
Updated on 22 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-0.3%
57,986
Compared to previous day
Last week
-0.8%
309,956
Compared to previous week
Last month
13.9%
1,358,353
Compared to previous month
Last year
120.1%
13,632,593
Compared to previous year
This project is a monorepo that contains several packages for dealing with math in markdown and HTML.
This repository contains unified (rehype and remark) plugins to add support for math. You can use them to add support for parsing and serializing a syntax extension and to render math with KaTeX or MathJax.
remark-math
— remark plugin to support a math syntax in markdownrehype-katex
— rehype plugin to render math in HTML with KaTeXrehype-mathjax
— rehype plugin to render math in HTML with MathJaxWhen dealing with markdown, you optionally use remark-math
, or alternatively
use fenced code (```math
).
Then, you either use rehype-katex
or rehype-mathjax
to render math in HTML.
This project is useful when you want to support LaTeX math.
This mechanism works well when you want authors, that have some LaTeX
experience, to be able to embed rich diagrams of math to scientific
documentation.
The extra syntax extension supported by remark-math
for math in markdown does
not work everywhere so it makes markdown less portable.
This project is also useful as it renders math with KaTeX or MathJax at compile
time, which means that there is no client side JavaScript needed.
Say our document example.md
contains:
1Lift($$L$$) can be determined by Lift Coefficient ($$C_L$$) like the following 2equation. 3 4$$ 5L = \frac{1}{2} \rho v^2 S C_L 6$$
…and our module example.js
contains:
1import rehypeKatex from 'rehype-katex' 2import rehypeStringify from 'rehype-stringify' 3import remarkMath from 'remark-math' 4import remarkParse from 'remark-parse' 5import remarkRehype from 'remark-rehype' 6import {read} from 'to-vfile' 7import {unified} from 'unified' 8 9const file = await unified() 10 .use(remarkParse) 11 .use(remarkMath) 12 .use(remarkRehype) 13 .use(rehypeKatex) 14 .use(rehypeStringify) 15 .process(await read('example.md')) 16 17console.log(String(file))
…then running node example.js
yields:
1<p>Lift(<code class="language-math math-inline"><span class="katex">…</span></code>) like the following 2equation.</p> 3<pre><code class="language-math math-display"><span class="katex-display"><span class="katex">…</span></span></code></pre>
👉 Note: KaTeX requires CSS to render correctly. Use
katex.css
somewhere on the page where the math is shown to style it properly:1<!-- Get the latest one from: https://katex.org/docs/browser --> 2<link href="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css" rel="stylesheet">
Supporting either MathJax or KaTeX is very similar. Take the above KaTeX example and change:
1@@ -1,4 +1,4 @@ 2-import rehypeKatex from 'rehype-katex' 3+import rehypeMathjax from 'rehype-mathjax' 4 import rehypeStringify from 'rehype-stringify' 5 import remarkMath from 'remark-math' 6 import remarkParse from 'remark-parse' 7@@ -10,7 +10,7 @@ const file = await unified() 8 .use(remarkParse) 9 .use(remarkMath) 10 .use(remarkRehype) 11- .use(rehypeKatex) 12+ .use(rehypeMathjax) 13 .use(rehypeStringify) 14 .process(await read('example.md'))
…then running node example.js
yields:
1<p>Lift(<mjx-container class="MathJax" jax="SVG"><!--…--></mjx-container>) can be determined by Lift Coefficient (<mjx-container class="MathJax" jax="SVG"><!--…--></mjx-container>) like the following 2equation.</p> 3<mjx-container class="MathJax" jax="SVG" display="true"><!--…--></mjx-container><style> 4mjx-container[jax="SVG"] { 5 direction: ltr; 6} 7/* … */ 8</style>
Assuming you trust KaTeX/MathJax, using rehype-katex
/rehype-mathjax
is
safe.
If a vulnerability is introduced in them, it opens you up to a
cross-site scripting (XSS) attack.
See their readmes for more info.
See contributing.md
in remarkjs/.github
for ways
to get started.
See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
MIT © Junyoung Choi and TANIGUCHI Masaya
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
0 commit(s) and 7 issue activity found in the last 90 days -- score normalized to 5
Reason
Found 2/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More