Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MathJax #51

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ include_content = true
[extra]
katex.enabled = true
katex.auto_render = true
# mathjax.enabled = true

chart.enabled = true
mermaid.enabled = true
Expand Down
11 changes: 10 additions & 1 deletion content/docs/config-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ katex.enabled = true
katex.auto_render = true # automatic rendering without shortcodes
```

### MathJax

Alternative math formula support using [MathJax](https://www.mathjax.org/).
To enable MathJax in your project, set the following in the `[extra]` section of `config.toml`:
```toml
[extra]
mathjax.enabled = true
```

# Section Configurations

Apart from standard config you can also add a `description` in your `_index.md` file for your sections that appears in listing.
Expand All @@ -133,4 +142,4 @@ In order to enable `comments` for your post change as below code snippet in your
```toml
[extra]
comments = true
```
```
20 changes: 19 additions & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,27 @@

<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/mathtex-script-type.min.js" integrity="sha384-jiBVvJ8NGGj5n7kJaiWwWp9AjC+Yh8rhZY3GtAX8yU28azcLgoRo4oukO87g7zDT" crossorigin="anonymous"></script>
{% if config.extra.katex.auto_render %}
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR" crossorigin="anonymous"></script>
{% endif %}
{% endif %}

{% if config.extra.mathjax.enabled %}
<script>
window.MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [['$$', '$$'], ['\[\[', '\]\]']],
processEscapes: true,
processEnvironments: true,
},
options: {
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
}
};
</script>
<script async defer src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" id="MathJax-script"></script>
{% endif %}

</head>

<body class="has-background-white">
Expand Down