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 /src/Zettel/Math.hs | |
parent | 6b1efad0b1d4bc6bf6db2892fd6a55d82c600f07 (diff) | |
download | zk-visual-6b797b52d65e0b174205bb12bc5075fed1825724.tar.gz zk-visual-6b797b52d65e0b174205bb12bc5075fed1825724.zip |
Add math support in Hugo with shortcodes
Diffstat (limited to 'src/Zettel/Math.hs')
-rw-r--r-- | src/Zettel/Math.hs | 23 |
1 files changed, 23 insertions, 0 deletions
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 |