Skip to content

Commit 1f13189

Browse files
committed
initial commit
0 parents  commit 1f13189

File tree

6 files changed

+1089
-0
lines changed

6 files changed

+1089
-0
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# markdown-it-katex
2+
3+
Add Math to your Markdown
4+
5+
KaTeX is fast. This plugin makes it easy to support it in your markdown.
6+
7+
## Usage
8+
9+
```
10+
npm install markdown-it-katex
11+
```
12+
13+
Include the KaTeX stylesheet in your html:
14+
```html
15+
<link rel="stylesheet"href="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min.css">
16+
```
17+
18+
If you're using the default markdown-it parser, I also recommend the github stylesheet:
19+
https://github.com/sindresorhus/github-markdown-css
20+
21+
## Examples
22+
23+
### Inline
24+
Surround your LaTeX with a single `$` on each side for inline rendering.
25+
```
26+
$\sqrt{3x-1}+(1+x)^2$
27+
```
28+
29+
### Block
30+
Use two (`$$`) for block rendering. This mode uses bigger symbols and centers
31+
the result.
32+
33+
```
34+
$$\begin{array}{c}
35+
36+
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} &
37+
= \frac{4\pi}{c}\vec{\mathbf{j}} \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
38+
39+
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
40+
41+
\nabla \cdot \vec{\mathbf{B}} & = 0
42+
43+
\end{array}$$
44+
```
45+
46+
## Math Syntax Support
47+
48+
KaTeX is based on TeX and LaTeX. Support for both is growing. Here's a list of
49+
currently supported functions:
50+
51+
[Function Support in KaTeX](https://github.com/Khan/KaTeX/wiki/Function-Support-in-KaTeX)

browser.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
var md = require('markdown-it')(),
2+
mk = require('./index');
3+
4+
md.use(mk);
5+
6+
var input = document.getElementById('input'),
7+
output = document.getElementById('output'),
8+
button = document.getElementById('button');
9+
10+
button.addEventListener('click', function(ev){
11+
12+
var result = md.render(input.value);
13+
14+
output.innerHTML = result;
15+
16+
});
17+
18+
/*
19+
20+
# Some Math
21+
22+
$\sqrt{3x-1}+(1+x)^2$
23+
24+
# Maxwells Equations
25+
26+
$\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t}
27+
= \frac{4\pi}{c}\vec{\mathbf{j}} \nabla \cdot \vec{\mathbf{E}} = 4 \pi \rho$
28+
29+
$\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} = \vec{\mathbf{0}}$ (curl of $\vec{\mathbf{E}}$ is proportional to the time derivative of $\vec{\mathbf{B}}$)
30+
31+
$\nabla \cdot \vec{\mathbf{B}} = 0$
32+
33+
34+
35+
\sqrt{3x-1}+(1+x)^2
36+
37+
c = \pm\sqrt{a^2 + b^2}
38+
39+
Maxwell's Equations
40+
41+
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t}
42+
= \frac{4\pi}{c}\vec{\mathbf{j}} \nabla \cdot \vec{\mathbf{E}} = 4 \pi \rho
43+
44+
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} = \vec{\mathbf{0}}
45+
46+
\nabla \cdot \vec{\mathbf{B}} = 0
47+
48+
Same thing in a LaTeX array
49+
\begin{array}{c}
50+
51+
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} &
52+
= \frac{4\pi}{c}\vec{\mathbf{j}} \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
53+
54+
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
55+
56+
\nabla \cdot \vec{\mathbf{B}} & = 0
57+
58+
\end{array}
59+
60+
61+
\begin{array}{c}
62+
y_1 \\
63+
y_2 \mathtt{t}_i \\
64+
z_{3,4}
65+
\end{array}
66+
67+
\begin{array}{c}
68+
x' &=& &x \sin\phi &+& z \cos\phi \\
69+
z' &=& - &x \cos\phi &+& z \sin\phi \\
70+
\end{array}
71+
72+
73+
74+
# Maxwell's Equations
75+
76+
77+
equation | description
78+
----------|------------
79+
$\nabla \cdot \vec{\mathbf{B}} = 0$ | divergence of $\vec{\mathbf{B}}$ is zero
80+
$\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} = \vec{\mathbf{0}}$ | curl of $\vec{\mathbf{E}}$ is proportional to the rate of change of $\vec{\mathbf{B}}$
81+
$\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} = \frac{4\pi}{c}\vec{\mathbf{j}} \nabla \cdot \vec{\mathbf{E}} = 4 \pi \rho$ | wha?
82+
83+
![electricity](http://i.giphy.com/Gty2oDYQ1fih2.gif)
84+
*/

0 commit comments

Comments
 (0)