Mercurial > repos > public > wdown
changeset 10:1ffe6e4f933c
Add math support through MathJax
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 17 Jun 2020 22:13:03 +0200 |
parents | 0a3841171c8f |
children | 4bcdc24edbe3 |
files | go.mod go.sum test.md test.tmpl wdown.go |
diffstat | 5 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/go.mod Wed Jun 17 22:12:32 2020 +0200 +++ b/go.mod Wed Jun 17 22:13:03 2020 +0200 @@ -4,6 +4,7 @@ require ( github.com/cbroglie/mustache v1.1.0 + github.com/litao91/goldmark-mathjax v0.0.0-20191101121019-011def32b12f github.com/yuin/goldmark v1.1.32 github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691 github.com/yuin/goldmark-meta v0.0.0-20191126180153-f0638e958b60
--- a/go.sum Wed Jun 17 22:12:32 2020 +0200 +++ b/go.sum Wed Jun 17 22:13:03 2020 +0200 @@ -33,6 +33,8 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/litao91/goldmark-mathjax v0.0.0-20191101121019-011def32b12f h1:mTnjnO2A0T4oKEKPK//Mqj8kerYOOLMDFxCqqznRGsY= +github.com/litao91/goldmark-mathjax v0.0.0-20191101121019-011def32b12f/go.mod h1:visY8Wq1v63x0pB96H2V3D/02Q32D6s37+q3ya1/gOM= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
--- a/test.md Wed Jun 17 22:12:32 2020 +0200 +++ b/test.md Wed Jun 17 22:13:03 2020 +0200 @@ -19,6 +19,13 @@ } ``` +## Math is also important +What would the world be like without some of this $f(x) = x^2 + 2x + 1$ +or even this +$$ +\zeta = \frac{1}{N}\sqrt{\sum_{i=1}^N \phi_i(x)} +$$ + ## Some logic We also need a table @@ -37,6 +44,14 @@ - [x] Allow template file as an input - [ ] Refactor main() to be readable - [x] Add possibility to have YAML metadata + - [ ] Try to add music score + - [ ] Test using v8go to render the music score server side + - [ ] Try to create an extension + +### Math + - [ ] Serve MathJax from own server. + - [ ] Keep investigating if it's possible to use _katex_ with _v8go_ to render math at compile time instead of realying on _MathJax_ to do it in the browser. + - [ ] Revisit the branch `javascript-experiment` and see if it's possible to get rid of the extra characters rendered by _katex_. ### Code highlighting - [ ] Check of other highlighters use the same kind of coloring idea
--- a/test.tmpl Wed Jun 17 22:12:32 2020 +0200 +++ b/test.tmpl Wed Jun 17 22:13:03 2020 +0200 @@ -2,6 +2,8 @@ <head> <title>{{title}}</title> <meta charset="UTF-8"> + <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> + <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3.0.1/es5/tex-mml-chtml.js"></script> </head> <body> {{{content}}}
--- a/wdown.go Wed Jun 17 22:12:32 2020 +0200 +++ b/wdown.go Wed Jun 17 22:13:03 2020 +0200 @@ -9,6 +9,7 @@ "os" "github.com/cbroglie/mustache" + mathjax "github.com/litao91/goldmark-mathjax" "github.com/yuin/goldmark" highlighting "github.com/yuin/goldmark-highlighting" meta "github.com/yuin/goldmark-meta" @@ -49,6 +50,7 @@ extension.GFM, highlighting.Highlighting, meta.Meta, + mathjax.MathJax, ), goldmark.WithParserOptions( parser.WithAutoHeadingID(),