Skip to content

Commit

Permalink
Switch to MathJax 3.x. Fixes alshedivat#115.
Browse files Browse the repository at this point in the history
  • Loading branch information
alshedivat committed Sep 23, 2020
1 parent 2614259 commit adfbe18
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 92 deletions.
10 changes: 3 additions & 7 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,8 @@ scholar:
# -----------------------------------------------------------------------------

enable_google_analytics: false
enable_katex: true
enable_mansory: true
enable_progressbar: true
enable_math: true
enable_tooltips: false
show_social_icons: false

Expand All @@ -170,11 +169,8 @@ fontawesome:
jquery:
version: "3.5.1"
integrity: "sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g=="
katex:
version: "0.12.0"
integrity:
css: "sha512-h7nl+xz8wgDlNM4NqKEM4F1NkIRS17M9+uJwIGwuo8vGqIl4BhuCKdxjWEINm+xyrUjNCnK5dCrhM0sj+wTIXw=="
js: "sha512-/CMIhXiDA3m2c9kzRyd97MTb3MC6OVnx4TElQ7fkkoRghwDf6gi41gaT1PwF270W6+J60uTmwgeRpNpJdRV6sg=="
mathjax:
version: "3.1.2"
mansory:
version: "4.2.2"
integrity: "sha256-Nn1q/fx0H7SNLZMQ5Hw5JLaTRZp0yILA/FRexe19VdI="
Expand Down
58 changes: 58 additions & 0 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<!-- Bootstrap & MDB -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/{{ site.bootstrap.version }}/css/bootstrap.min.css" rel="stylesheet" integrity="{{ site.bootstrap.integrity.css }}" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/{{ site.mdb.version }}/css/mdb.min.css" integrity="{{ site.mdb.integrity.css }}" crossorigin="anonymous" />
<script defer src="https://code.jquery.com/jquery-{{ site.jquery.version }}.slim.min.js" integrity="{{ site.jquery.integrity }}" crossorigin="anonymous"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/{{ site.popper.version }}/umd/popper.min.js" integrity="{{ site.popper.integrity }}" crossorigin="anonymous"></script>
<script defer src="https://stackpath.bootstrapcdn.com/bootstrap/{{ site.bootstrap.version }}/js/bootstrap.min.js" integrity="{{ site.bootstrap.integrity.js }}" crossorigin="anonymous"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/{{ site.mdb.version }}/js/mdb.min.js" integrity="{{ site.mdb.integrity.js }}" crossorigin="anonymous"></script>

<!-- Fonts & Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/{{ site.fontawesome.version }}/css/all.min.css" integrity="{{ site.fontawesome.integrity }}" crossorigin="anonymous">
Expand All @@ -29,3 +33,57 @@
<meta property="og:description" content="{{ page.title }}" />
<meta property="og:image" content="{%- if page.og_image -%}{{ page.og_image }}{%- else -%}{{ site.og_image }}{%- endif -%}" />
{% endif %}

<!-- Load Common JS -->
<script defer src="{{ '/assets/js/common.js' | relative_url }}"></script>

<!-- Code Syntax Highlighting -->
<link rel="stylesheet" href="https://gitcdn.link/repo/jwarby/jekyll-pygments-themes/master/{{ site.highlight_theme }}.css" />

{% if site.enable_math %}
<!-- Load MathJax -->
<script defer type="text/javascript" id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@{{ site.mathjax.version }}/es5/tex-mml-chtml.js"></script>
<script defer src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
{% endif %}

{% if site.enable_mansory %}
<!-- Load Mansory & imagesLoaded -->
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/masonry/{{ site.mansory.version }}/masonry.pkgd.min.js" integrity="{{ site.masonry.integrity }}" crossorigin="anonymous"></script>
<script defer src="https://unpkg.com/imagesloaded@4/imagesloaded.pkgd.min.js"></script>

<!-- Project Cards Layout -->
<script defer type="text/javascript">
// Init Masonry
var $grid = $('.grid').masonry({
gutter: 10,
horizontalOrder: true,
itemSelector: '.grid-item',
});
// layout Masonry after each image loads
$grid.imagesLoaded().progress( function() {
$grid.masonry('layout');
});
</script>
{% endif %}

{% if site.enable_tooltips %}
<!-- Enable Tooltips -->
<script defer type="text/javascript">
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
</script>
{% endif %}

{% if site.enable_google_analytics %}
<!-- Google Analytics -->
<script defer>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}
60 changes: 0 additions & 60 deletions _includes/hemline.html

This file was deleted.

2 changes: 0 additions & 2 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,4 @@

</body>

{% include hemline.html %}

</html>
4 changes: 1 addition & 3 deletions _layouts/distill.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</head>

<d-front-matter>
<script type="text/json">{
<script async type="text/json">{
"title": "{{ page.title }}",
"description": "{{ page.description }}",
"published": "{{ page.date }}",
Expand Down Expand Up @@ -81,8 +81,6 @@ <h1>{{ page.title }}</h1>

</body>

{% include hemline.html %}

<d-bibliography src="{{ page.bibliography | prepend: '/assets/bibliography/' | relative_url }}">
</d-bibliography>

Expand Down
4 changes: 2 additions & 2 deletions _posts/2015-10-20-math.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ title: a post with math
date: 2015-10-20 11:12:00-0400
description: an example of a blog post with some math
---
This theme supports rendering beautiful math in inline and display modes using [KaTeX](https://khan.github.io/KaTeX/) engine. You just need to surround your math expression with `$$`, like `$$ E = mc^2 $$`. If you leave it inside a paragraph, it will produce an inline expression, just like $$ E = mc^2 $$.
This theme supports rendering beautiful math in inline and display modes using [MathJax 3](https://www.mathjax.org/){:target="\_blank"} engine. You just need to surround your math expression with `$$`, like `$$ E = mc^2 $$`. If you leave it inside a paragraph, it will produce an inline expression, just like $$ E = mc^2 $$.

To use display mode, again surround your expression with `$$` and place it as a separate paragraph. Here is an example:

$$
\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)
$$

Note that [KaTeX](https://khan.github.io/KaTeX/) is work in progress, so it does not support the full range of math expressions as, say, [MathJax](https://www.mathjax.org/). Yet, it is [blazing fast](http://www.intmath.com/cg5/katex-mathjax-comparison.php).
Note that MathJax 3 is [a major re-write of MathJax](https://docs.mathjax.org/en/latest/upgrading/whats-new-3.0.html){:target="\_blank"} that brought a significant improvement to the loading and rendering speed, which is now [on par with KaTeX](http://www.intmath.com/cg5/katex-mathjax-comparison.php){:target="\_blank"}.
6 changes: 3 additions & 3 deletions _posts/2018-12-22-distill.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ _styles: >

## Equations

This theme supports rendering beautiful math in inline and display modes using [KaTeX](https://khan.github.io/KaTeX/) engine.
This theme supports rendering beautiful math in inline and display modes using [MathJax 3](https://www.mathjax.org/){:target="\_blank"} engine.
You just need to surround your math expression with `$$`, like `$$ E = mc^2 $$`.
If you leave it inside a paragraph, it will produce an inline expression, just like $$ E = mc^2 $$.

Expand All @@ -53,8 +53,8 @@ $$
\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)
$$

Note that [KaTeX](https://khan.github.io/KaTeX/) is work in progress, so it does not support the full range of math expressions as, say, [MathJax](https://www.mathjax.org/).
Yet, it is [blazing fast](http://www.intmath.com/cg5/katex-mathjax-comparison.php).
Note that MathJax 3 is [a major re-write of MathJax](https://docs.mathjax.org/en/latest/upgrading/whats-new-3.0.html){:target="\_blank"} that brought a significant improvement to the loading and rendering speed, which is now [on par with KaTeX](http://www.intmath.com/cg5/katex-mathjax-comparison.php){:target="\_blank"}.


***

Expand Down
15 changes: 0 additions & 15 deletions assets/js/katex.js

This file was deleted.

0 comments on commit adfbe18

Please sign in to comment.