Skip to content

Commit 4b22738

Browse files
committed
Fixed inline math typesetting
1 parent 7b82f07 commit 4b22738

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

hakyll-jobbel.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ executable site
99
, hakyll == 4.16.*
1010
, time
1111
, containers
12+
, pandoc
1213
ghc-options: -threaded -rtsopts -with-rtsopts=-N
1314
default-language: Haskell2010

js/post.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
function renderMath() {
2-
renderMathInElement(document.body, {
3-
delimiters: [
4-
{ left: "$$", right: "$$", display: true },
5-
{ left: "$", right: "$", display: false },
6-
{ left: "\\(", right: "\\)", display: false },
7-
{ left: "\\[", right: "\\]", display: true }
8-
]
9-
});
2+
const inlineMath = document.querySelectorAll("span.math.inline");
3+
for (const element of inlineMath) {
4+
katex.render(element.innerText, element);
5+
}
6+
7+
const displayMath = document.querySelectorAll("span.math.display");
8+
for (const element of displayMath) {
9+
katex.render(element.innerText, element, {
10+
displayMode: true
11+
});
12+
}
13+
14+
// renderMathInElement(document.body, {
15+
// delimiters: [
16+
// { left: "$$", right: "$$", display: true },
17+
// { left: "$", right: "$", display: false },
18+
// { left: "\\(", right: "\\)", display: false },
19+
// { left: "\\[", right: "\\]", display: true }
20+
// ]
21+
// });
1022
}
1123

1224
const codeBlocks = Array.from(document.querySelectorAll("pre code"));

site.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Data.Time.Calendar.OrdinalDate
88
import Data.Time.Clock
99
import Data.Time.Format
1010
import Hakyll
11+
import Text.Pandoc.Options
1112

1213
--------------------------------------------------------------------------------
1314
main :: IO ()
@@ -23,7 +24,9 @@ main = hakyll $ do
2324
match "posts/*" $ do
2425
route $ setExtension "html"
2526
compile $
26-
pandocCompiler
27+
pandocCompilerWith
28+
defaultHakyllReaderOptions
29+
defaultHakyllWriterOptions{writerHTMLMathMethod = KaTeX ""}
2730
>>= loadAndApplyTemplate "templates/post.html" postCtx
2831
>>= loadAndApplyTemplate "templates/default.html" postCtx
2932
>>= relativizeUrls

templates/post.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
defer
1717
src="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/katex.min.js"
1818
integrity="sha384-RdymN7NRJ+XoyeRY4185zXaxq9QWOOx3O7beyyrRK4KQZrPlCDQQpCu95FoCGPAE"
19-
crossorigin="anonymous"></script>
20-
<script
21-
defer
22-
src="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/contrib/auto-render.min.js"
23-
integrity="sha384-hCXGrW6PitJEwbkoStFjeJxv+fSOOQKOPbJxSfM6G5sWZjAyWhXiTIIAmQqnlLlh"
2419
crossorigin="anonymous"
2520
onload="renderMath()"></script>
2621

0 commit comments

Comments
 (0)