Skip to content

Commit

Permalink
KaTeX support (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
reptee authored Jan 1, 2024
1 parent aaadf20 commit fb78d7b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
18 changes: 17 additions & 1 deletion docs/tips/js/math.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ page:

# Math

## MathJax

[MathJax](https://www.mathjax.org) can be used to render Math formulas. For example, $a^2 + b ^ 2 = c$.

To enable it, add the following to `page.headHtml` of [[yaml-config|YAML configuration]] or Markdown frontmatter.
Expand All @@ -18,7 +20,21 @@ page:
<snippet var="js.mathjax" />
```
## Demo
### Demo
When $a \ne 0$, there are two solutions to $ax^2 + bx + c = 0$ and they are
$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
## KaTeX
[KaTeX](https://katex.org/) can be used as an alternative to MathJax. Just like MathJax, it renders math specified between dollar signs.
To enable it:
```yaml
page:
headHtml: |
<snippet var="js.katex" />
```
1 change: 1 addition & 0 deletions emanote/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- The semantics of `folder-folgezettel` is now applied in inverse (see docs)
- Allow specifying custom page title in sidebar ([\#488](https://github.com/srid/emanote/pull/488))
- Allow specifying `lang` attribute for HTML page in YAML config ([\#485](https://github.com/srid/emanote/pull/485))
- KaTeX support ([\#489](https://github.com/srid/emanote/pull/489))
- Bug fixes:
- Emanote no longer crashes when run on an empty directory ([\#487](https://github.com/srid/emanote/issues/487))

Expand Down
14 changes: 14 additions & 0 deletions emanote/default/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,20 @@ js:
};
</script>
<script async="" id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
katex: |
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
integrity="sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV"
crossorigin="anonymous">
<script defer
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
integrity="sha384-XjKyOOlGwcjNTAIQHIpgOno0Hl1YQqzUOEleOLALmuqehneUG+vnGctmUb0ZY0l8"
crossorigin="anonymous"></script>
<script defer
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"
integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05"
crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>
emanote:
# Whether to automatically treat folder notes as a folgezettel parent of its contents
Expand Down
2 changes: 1 addition & 1 deletion emanote/emanote.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.4
name: emanote
version: 1.3.3.0
version: 1.3.4.0
license: AGPL-3.0-only
copyright: 2022 Sridhar Ratnakumar
maintainer: [email protected]
Expand Down

0 comments on commit fb78d7b

Please sign in to comment.