diff options
author | Yann Herklotz <git@yannherklotz.com> | 2023-05-12 22:28:07 +0100 |
---|---|---|
committer | Yann Herklotz <git@yannherklotz.com> | 2023-05-12 22:28:07 +0100 |
commit | 6b797b52d65e0b174205bb12bc5075fed1825724 (patch) | |
tree | da39e6b27b95e4da2bc336eb2ddc0242d8f66835 | |
parent | 6b1efad0b1d4bc6bf6db2892fd6a55d82c600f07 (diff) | |
download | zk-visual-6b797b52d65e0b174205bb12bc5075fed1825724.tar.gz zk-visual-6b797b52d65e0b174205bb12bc5075fed1825724.zip |
Add math support in Hugo with shortcodes
-rw-r--r-- | org-zk.cabal | 1 | ||||
-rw-r--r-- | src/Main.hs | 3 | ||||
-rw-r--r-- | src/Zettel.hs | 2 | ||||
-rw-r--r-- | src/Zettel/Math.hs | 23 |
4 files changed, 28 insertions, 1 deletions
diff --git a/org-zk.cabal b/org-zk.cabal index fda804d..bca2ac2 100644 --- a/org-zk.cabal +++ b/org-zk.cabal @@ -52,6 +52,7 @@ executable org-zk other-modules: Zettel , Zettel.Common , Zettel.Links + , Zettel.Math , Zettel.Parse , Zettel.Render , Zettel.Transclusion diff --git a/src/Main.hs b/src/Main.hs index b66d2ab..1e1094a 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -212,5 +212,6 @@ main = do graph' <- parseZettelKasten fl let graph = transcludeMdAll graph' let linkedGraph = linkAll graph - renderZettelGraphFile "../zk-web/content/zettel" linkedGraph + let wrappedGraph = wrapZettelGraph linkedGraph + renderZettelGraphFile "../zk-web/content/zettel" wrappedGraph return () diff --git a/src/Zettel.hs b/src/Zettel.hs index 8c4720b..6846263 100644 --- a/src/Zettel.hs +++ b/src/Zettel.hs @@ -4,6 +4,7 @@ module Zettel module Zettel.Links, module Zettel.Parse, module Zettel.Transclusion, + module Zettel.Math, ) where @@ -12,3 +13,4 @@ import Zettel.Parse import Zettel.Render import Zettel.Transclusion import Zettel.Types +import Zettel.Math diff --git a/src/Zettel/Math.hs b/src/Zettel/Math.hs new file mode 100644 index 0000000..226f515 --- /dev/null +++ b/src/Zettel/Math.hs @@ -0,0 +1,23 @@ +{-# LANGUAGE OverloadedRecordDot #-} + +module Zettel.Math where + +import Text.Pandoc.Definition (Inline (..), Pandoc (..)) +import Text.Pandoc.Walk (walk) +import Zettel.Types + +wrapMath :: [Inline] -> [Inline] +wrapMath = concatMap f + where + f :: Inline -> [Inline] + f m@(Math _ _) = [RawInline "markdown" "{{< math >}}", m, RawInline "markdown" "{{< /math >}}"] + f a = [a] + +wrapMathPandoc :: Pandoc -> Pandoc +wrapMathPandoc = walk wrapMath + +wrapZettel :: Zettel -> Zettel +wrapZettel z = z {zettelBody = wrapMathPandoc z.zettelBody} + +wrapZettelGraph :: ZettelGraph -> ZettelGraph +wrapZettelGraph = ZettelGraph . fmap wrapZettel . unZettelGraph |