nani.wtf/static-site-generator/Preprocessing/Graphviz.hs

22 lines
536 B
Haskell

{-# LANGUAGE OverloadedStrings #-}
module Preprocessing.Graphviz where
import Data.Text (Text, pack, unpack)
import System.Process ( readProcess )
import Text.Pandoc
( Pandoc,
Block (RawBlock, CodeBlock),
Format (Format),
)
codeBlock :: Block -> IO Block
codeBlock cb@(CodeBlock (id, classes, namevals) contents)
| "dot" `elem` classes = RawBlock (Format "html") . pack <$> svg (unpack contents)
| otherwise = return cb
codeBlock x = return x
svg :: String -> IO String
svg = readProcess "dot" ["-Tsvg"]
-- PlantUML