Created
January 8, 2015 09:46
-
-
Save jorpic/a65d7cba367759f28738 to your computer and use it in GitHub Desktop.
MathJax + Markdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<script type="text/x-mathjax-config"> | |
MathJax.Hub.Config({ | |
tex2jax: { | |
inlineMath: [["$","$"]], | |
skipTags: ['script', 'noscript', 'style'] | |
} | |
}); | |
</script> | |
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/marked/0.3.2/marked.min.js"></script> | |
<link href="https://stackedit.io/res-min/themes/default.css" type="text/css" rel="stylesheet"> | |
<style> | |
.wrapper { | |
max-width: 900px; | |
margin: 0 auto; | |
} | |
</style> | |
</head> | |
<body> | |
<script id="text" type="text/plain"> | |
Markdown + MathJax | |
===== | |
Markdown может испортить $\LaTeX$-формулы. Например, в формуле | |
`x = f * g * h`, он заменит `* g *` на `<em> g </em>`. | |
В этом случае его можно обмануть его используя `\ast` вместо звёздочки. | |
$$ | |
x = f \ast g \ast h | |
$$ | |
Выключную формулу можно защитить от markdown'а завернув её в тройные | |
кавычки. | |
Как-то так: | |
``` | |
$$ | |
\begin{align} | |
\cos(nx) & = \mathrm{Re} \{\ e^{inx}\ \} | |
= \mathrm{Re} \{\ e^{i(n-1)x}\cdot e^{ix}\ \} \\ | |
& = \mathrm{Re} \{\ e^{i(n-1)x}\cdot (\underbrace{e^{ix} + e^{-ix}}_{2\cos(x)} - e^{-ix})\ \} \\ | |
& = \mathrm{Re} \{\ e^{i(n-1)x}\cdot 2\cos(x) - e^{i(n-2)x}\ \} \\ | |
& = \cos[(n-1)x]\cdot 2 \cos(x) - \cos[(n-2)x] \ | |
\end{align} | |
$$ | |
``` | |
</script> | |
<script> | |
var text = document.getElementById('text').innerText; | |
var div = document.createElement('div'); | |
div.innerHTML = marked(text); | |
div.className = 'wrapper'; | |
document.body.appendChild(div); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment