1{-# LANGUAGE NoImplicitPrelude #-}
2{-# LANGUAGE TupleSections #-}
4Copyright (C) 2012-2018 John MacFarlane <jgm@berkeley.edu>
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22import Text.Pandoc.Error (PandocError(..))
23import Control.Monad.Except (throwError)
24import qualified Text.Pandoc.UTF8 as UTF8
25import qualified Data.ByteString as B
27import Criterion.Types (Config(..))
28import Data.List (intersect)
29import Data.Maybe (mapMaybe)
30import System.Environment (getArgs)
37 Right (readerFun, inp) ->
38 Just $ bench (name ++ " reader")
39 $ nf (\i -> either (error . show) id $ runPure (readerFun i))
43 case (getReader name, getWriter name) of
44 (Right (TextReader r, rexts),
45 Right (TextWriter w, wexts)) -> do
46 inp <- w def{ writerWrapText = WrapAuto
47 , writerExtensions = wexts } doc
48 return $ (r def{ readerExtensions = rexts }, inp)
49 _ -> throwError $ PandocSomeError
50 $ "could not get text reader and writer for " ++ name
58 Just $ bench (name ++ " writer")
59 $ nf (\d -> either (error . show) id $
60 runPure (writerFun d)) doc
62 where res = runPure $ do
63 case (getWriter name) of
64 Right (TextWriter w, wexts) ->
65 return $ w def{ writerExtensions = wexts }
66 _ -> throwError $ PandocSomeError
67 $ "could not get text reader and writer for " ++ name
71 args <- filter (\x -> take 1 x /= "-") <$> getArgs
73 let matchReader (n, TextReader _) =
74 null args || ("reader" `elem` args && n `elem` args)
76 let matchWriter (n, TextWriter _) =
77 null args || ("writer" `elem` args && n `elem` args)
79 let matchedReaders = map fst $ (filter matchReader readers
80 :: [(String, Reader PandocPure)])
81 let matchedWriters = map fst $ (filter matchWriter writers
82 :: [(String, Writer PandocPure)])
83 inp <- UTF8.toText <$> B.readFile "test/testsuite.txt"
85 let doc = either (error . show) id $ runPure $ readMarkdown opts inp
86 let readerBs = mapMaybe (readerBench doc)
87 $ filter (/="haddock")
88 (matchedReaders `intersect` matchedWriters)
89 -- we need the corresponding writer to generate
90 -- input for the reader
91 let writerBs = mapMaybe (writerBench doc) matchedWriters
92 defaultMainWith defaultConfig{ timeLimit = 6.0 }
93 (writerBs ++ readerBs)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list