git.iko.soy/typeable/pandoc
on 2.1 help sign in
typeable/pandoc/benchmark/weigh-pandoc.hs
38 lines 1.2 kB history raw
1import Weigh
2import Text.Pandoc
3import Data.Text (Text)
5main :: IO ()
6main = do
7 doc <- read <$> readFile "test/testsuite.native"
8 mainWith $ do
9 func "Pandoc document" id doc
10 mapM_
11 (\(n,r) -> weighReader doc n (either (error . show) id . runPure . r def{readerExtensions = pandocExtensions}))
12 [("markdown", readMarkdown)
13 ,("html", readHtml)
14 ,("docbook", readDocBook)
15 ,("latex", readLaTeX)
16 ,("commonmark", readCommonMark)
17 ]
18 mapM_
19 (\(n,w) -> weighWriter doc n (either (error . show) id . runPure . w def))
20 [("markdown", writeMarkdown)
21 ,("html", writeHtml5String)
22 ,("docbook", writeDocbook5)
23 ,("latex", writeLaTeX)
24 ,("commonmark", writeCommonMark)
25 ]
27weighWriter :: Pandoc -> String -> (Pandoc -> Text) -> Weigh ()
28weighWriter doc name writer = func (name ++ " writer") writer doc
30weighReader :: Pandoc -> String -> (Text -> Pandoc) -> Weigh ()
31weighReader doc name reader = do
32 case lookup name writers of
33 Just (TextWriter writer) ->
34 let inp = either (error . show) id $ runPure $ writer def{ writerWrapText = WrapAuto} doc
35 in func (name ++ " reader") reader inp
36 _ -> return () -- no writer for reader