Skip to content

Commit

Permalink
Add Mathjax files to build step
Browse files Browse the repository at this point in the history
  • Loading branch information
emad-elsaid committed Jun 8, 2024
1 parent c4d3ad9 commit ecfe9de
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions extensions/mathjax/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mathjax
import (
"bytes"
"embed"
"io/fs"

. "github.com/emad-elsaid/xlog"
"github.com/yuin/goldmark/ast"
Expand All @@ -27,12 +28,29 @@ MathJax = {

func init() {
RegisterStaticDir(js)
registerBuildFiles()
MarkDownRenderer.Renderer().AddOptions(renderer.WithNodeRenderers(
util.Prioritized(&InlineMathRenderer{startDelim: `\(`, endDelim: `\)`}, 0),
util.Prioritized(&MathBlockRenderer{startDelim: `\[`, endDelim: `\]`}, 0),
))
}

func registerBuildFiles() {
fs.WalkDir(js, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}

if d.IsDir() {
return nil
}

RegisterBuildPage("/"+path, false)

return nil
})
}

type InlineMathRenderer struct {
startDelim string
endDelim string
Expand Down

0 comments on commit ecfe9de

Please sign in to comment.