Gathering detailed insights and metrics for @vscode/markdown-it-katex
Gathering detailed insights and metrics for @vscode/markdown-it-katex
Add Math to your Markdown with a KaTeX plugin for Markdown-it
npm install @vscode/markdown-it-katex
Typescript
Module System
Node Version
TypeScript (88.03%)
JavaScript (11.97%)
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Total Downloads
661,254
Last Day
2,358
Last Week
15,255
Last Month
65,009
Last Year
519,282
NOASSERTION License
38 Stars
177 Commits
20 Forks
3 Watchers
6 Branches
66 Contributors
Updated on Mar 13, 2025
Minified
Minified + Gzipped
Latest Version
1.1.1
Package Id
@vscode/markdown-it-katex@1.1.1
Unpacked Size
24.98 kB
Size
6.78 kB
File Count
5
Node Version
18.5.0
Published on
Dec 11, 2024
Cumulative downloads
Total Downloads
Last Day
-5.3%
2,358
Compared to previous day
Last Week
-0.4%
15,255
Compared to previous week
Last Month
-5.4%
65,009
Compared to previous month
Last Year
285.9%
519,282
Compared to previous year
1
Markdown It plugin that adds KaTeX rendering. This is used by VS Code to render math in Markdown.
Originally forked from @iktakahiro/markdown-it-katex
Install markdown-it
1npm install markdown-it
Install the plugin
1npm install @vscode/markdown-it-katex
Use it in your javascript
1var md = require('markdown-it')(), 2 mk = require('@vscode/markdown-it-katex').default; 3 4md.use(mk); 5 6// double backslash is required for javascript strings, but not html input 7var result = md.render('# Math Rulez! \n $\\sqrt{3x-1}+(1+x)^2$');
Include the KaTeX stylesheet in your html:
1<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.4/dist/katex.min.css">
If you're using the default markdown-it parser, I also recommend the github stylesheet:
1<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/4.0.0/github-markdown.min.css"/>
KaTeX
options can be supplied with the second argument to use.
1md.use(mk, {"throwOnError" : false, "errorColor" : " #cc0000"});
Surround your LaTeX with a single $
on each side for inline rendering.
1$\sqrt{3x-1}+(1+x)^2$
Use two ($$
) for block rendering. This mode uses bigger symbols and centers
the result.
1$$\begin{array}{c} 2 3\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & 4= \frac{4\pi}{c}\vec{\mathbf{j}} \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\ 5 6\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\ 7 8\nabla \cdot \vec{\mathbf{B}} & = 0 9 10\end{array}$$
1import MarkdownIt from 'markdown-it' 2import katex from 'katex' 3import 'katex/contrib/mhchem' 4import 'katex/contrib/copy-tex' 5const md = new MarkdownIt() 6katexPlugin(md, { 7 katex, 8}) 9 10const result = md.render('# Math Rulez! \n $\\sqrt{3x-1}+(1+x)^2$'); 11const chemResult = md.render('$\\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$')
Math parsing in markdown is designed to agree with the conventions set by pandoc:
Anything between two $ characters will be treated as TeX math. The opening $ must
have a non-space character immediately to its right, while the closing $ must
have a non-space character immediately to its left, and must not be followed
immediately by a digit. Thus, $20,000 and $30,000 won’t parse as math. If for some
reason you need to enclose text in literal $ characters, backslash-escape them and
they won’t be treated as math delimiters.
KaTeX is based on TeX and LaTeX. Support for both is growing. Here's a list of currently supported functions:
No vulnerabilities found.
No security vulnerabilities found.