Add TeX math equations to your Markdown documents rendered by markdown-it parser. KaTeX is used as a fast math renderer.
Simplify the process of authoring markdown documents containing math formulas. This extension is a comfortable tool for scientists, engineers and students with markdown as their first choice document format.
- Macro support
- Simple formula numbering
- Inline math with tables, lists and blockquote.
- User setting delimiters:
'dollars'
(default)- inline:
$...$
- display:
$$...$$
- display + equation number:
$$...$$ (1)
- inline:
'brackets'
- inline:
\(...\)
- display:
\[...\]
- display + equation number:
\[...\] (1)
- inline:
'gitlab'
- inline:
$`...`$
- display:
```math ... ```
- display + equation number:
```math ... ``` (1)
- inline:
'kramdown'
- inline:
$$...$$
- display:
$$...$$
- display + equation number:
$$...$$ (1)
- inline:
View a test table.
Install the extension. Verify having markdown-it
and katex
already installed .
npm install markdown-it-texmath
Use it with JavaScript.
let kt = require('katex'),
tm = require('markdown-it-texmath').use(kt),
md = require('markdown-it')().use(tm,{delimiters:'dollars',macros:{"\\RR": "\\mathbb{R}"}});
md.render('Euler\'s identity \(e^{i\pi}+1=0\) is a beautiful formula in $\\RR 2$.')
<html>
<head>
<meta charset='utf-8'>
<link rel="stylesheet" href="katex.min.css">
<link rel="stylesheet" href="texmath.css">
<script src="markdown-it.min.js"></script>
<script src="katex.min.js"></script>
<script src="texmath.js"></script>
</head>
<body>
<div id="out"></div>
<script>
let md;
document.addEventListener("DOMContentLoaded", () => {
const tm = texmath.use(katex);
md = markdownit().use(tm,{delimiters:'dollars',macros:{"\\RR": "\\mathbb{R}"}});
out.innerHTML = md.render('Euler\'s identity $e^{i\pi}+1=0$ is a beautiful formula in //RR 2.');
})
</script>
</body>
</html>
Use following links for texmath.js
and texmath.css
https://gitcdn.xyz/cdn/goessner/markdown-it-texmath/master/texmath.js
https://gitcdn.xyz/cdn/goessner/markdown-it-texmath/master/texmath.css
markdown-it
: Markdown parser done right. Fast and easy to extend.katex
: This is where credits for fast rendering TeX math in HTML go to.
nothing yet
- Add support for Tex macros (https://katex.org/docs/supported.html#macros) .
- Bug with brackets delimiters .
- Add support for Kramdown .
- Fatal blockquote bug investigated. Implemented workaround to vscode bug, which has finally gone with vscode 1.26.0 .
- Escaped underscore bug removed.
- Backslash bug removed.
- Modifying the
block
mode regular expression withgitlab
delimiters, so removing thenewline
bug.
markdown-it-texmath
is licensed under the MIT License