Skip to content

Commit

Permalink
Merge pull request rohanchandra#75 from saojeda/saojeda-updates
Browse files Browse the repository at this point in the history
KaTeX updates and optimizations
  • Loading branch information
rohanchandra authored Jun 6, 2018
2 parents a5212e9 + 61b9ae4 commit 4eda1cb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion _includes/footer.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% if site.theme_settings.katex %}
{% if site.theme_settings.katex and page.id %}
<script src="{{ "/assets/js/katex_init.js" | relative_url }}"></script>
{% endif %}

Expand Down
6 changes: 3 additions & 3 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
{% endif %}

<!-- KaTeX -->
{% if site.theme_settings.katex %}
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.8.3/katex.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.8.3/katex.min.js"></script>
{% if site.theme_settings.katex and page.id %}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-BTL0nVi8DnMrNdMQZG1Ww6yasK9ZGnUxL1ZWukXQ7fygA1py52yPp9W4wrR00VML" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-y6SGsNt7yZECc4Pf86XmQhC4hG2wxL6Upkt9N1efhFxfh6wlxBH0mJiTE8XYclC1" crossorigin="anonymous"></script>
{% endif %}

<!-- Google Analytics -->
Expand Down
3 changes: 2 additions & 1 deletion assets/js/katex_init.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ Array.prototype.forEach.call(elements, function(element) {
if (element.type.indexOf('mode=display') != -1){
katexElement.className += "math-display";
textToRender = '\\displaystyle {' + textToRender + '}';
katex.render(textToRender, katexElement, {displayMode: true});
} else {
katexElement.className += "math-inline";
katex.render(textToRender, katexElement);
}

katex.render(textToRender, katexElement);
element.parentNode.insertBefore(katexElement, element);
}
});

0 comments on commit 4eda1cb

Please sign in to comment.