- Switch from `cabal2nix` and haskell overlay to `developPackage` - Restructure directories to have more descriptive names - Fix `nix run`
22 lines
536 B
Haskell
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 |