Skip to content

Commit

Permalink
replace <code>$math$</code> with <code>\(math\)</code>, so that we do…
Browse files Browse the repository at this point in the history
… not really need to configure MathJax!
  • Loading branch information
yihui committed Jul 13, 2017
1 parent c1cfac7 commit 2838faa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 0 additions & 8 deletions layouts/partials/footer_mathjax.html
@@ -1,12 +1,4 @@
{{ if and (not .Params.disable_mathjax) (or (in (string .Content) "\\") (in (string .Content) "$")) }}
<script src="{{ "/js/math-code.js" | relURL }}"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$','$'], ['\\(','\\)']],
processEscapes: true
}
});
</script>
<script async src="{{ .Site.Params.MathJaxCDN | default "//cdn.bootcss.com" }}/mathjax/{{ .Site.Params.MathJaxVersion | default "2.7.1" }}/MathJax.js?config=TeX-MML-AM_CHTML"></script>
{{ end }}
4 changes: 4 additions & 0 deletions static/js/math-code.js
Expand Up @@ -4,6 +4,10 @@
code = codes[i];
if (code.parentNode.tagName !== 'PRE' && code.childElementCount === 0) {
text = code.textContent;
if (/^\$[^$](.|\s)+[^$]\$$/.test(text)) {
text = text.replace(/^\$/, '\\(').replace(/\$$/, '\\)');
code.textContent = text;
}
if (/^\\\((.|\s)+\\\)$/.test(text) || /^\\\[(.|\s)+\\\]$/.test(text) ||
/^\$(.|\s)+\$$/.test(text) ||
/^\\begin\{([^}]+)\}(.|\s)+\\end\{[^}]+\}$/.test(text)) {
Expand Down

0 comments on commit 2838faa

Please sign in to comment.