diff options
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 |