@@ -70,30 +70,10 @@ module Text.Pandoc
7070 , setVerbosity
7171 -- * Error handling
7272 , module Text.Pandoc.Error
73− -- * Lists of readers and writers
74− , readers
75− -- , writers
73+ -- * Lists of writers
7674 , writers
7775 -- * Readers: converting /to/ Pandoc format
78− , Reader (..)
79− , readDocx
80− , readOdt
81− , readMarkdown
82− , readCommonMark
83− , readMediaWiki
84− , readRST
85− , readOrg
86− , readLaTeX
87− , readHtml
88− , readTextile
89− , readDocBook
90− , readOPML
91− , readHaddock
92− , readNative
93− , readJSON
94− , readTWiki
95− , readTxt2Tags
96− , readEPUB
76+ , module Text.Pandoc.Readers
9777 -- * Writers: converting /from/ Pandoc format
9878 , Writer(..)
9979 , writeNative
@@ -142,12 +122,10 @@ module Text.Pandoc
142122 -- * Rendering templates and default templates
143123 , module Text.Pandoc.Templates
144124 -- * Miscellaneous
145− , getReader
146125 , getWriter
147126 , pandocVersion
148127 ) where
149128
150−import Control.Monad.Except (throwError)
151129import Data.Aeson
152130import qualified Data.ByteString.Lazy as BL
153131import Data.List (intercalate)
@@ -157,24 +135,8 @@ import Text.Pandoc.Error
157135import Text.Pandoc.Generic
158136import Text.Pandoc.Logging
159137import Text.Pandoc.Options
160−import Text.Pandoc.Readers.CommonMark
161−import Text.Pandoc.Readers.DocBook
162−import Text.Pandoc.Readers.Docx
163−import Text.Pandoc.Readers.EPUB
164−import Text.Pandoc.Readers.Haddock
165−import Text.Pandoc.Readers.HTML
166−import Text.Pandoc.Readers.LaTeX
167−import Text.Pandoc.Readers.Markdown
168−import Text.Pandoc.Readers.MediaWiki
169−import Text.Pandoc.Readers.Native
170−import Text.Pandoc.Readers.Odt
171−import Text.Pandoc.Readers.OPML
172−import Text.Pandoc.Readers.Org
173−import Text.Pandoc.Readers.RST
174−import Text.Pandoc.Readers.Textile
175−import Text.Pandoc.Readers.TWiki
176−import Text.Pandoc.Readers.Txt2Tags
177−import Text.Pandoc.Shared (mapLeft, pandocVersion)
138+import Text.Pandoc.Readers
139+import Text.Pandoc.Shared (pandocVersion)
178140import Text.Pandoc.Templates
179141import qualified Text.Pandoc.UTF8 as UTF8
180142import Text.Pandoc.Writers.AsciiDoc
@@ -209,38 +171,6 @@ import Text.Pandoc.Writers.Textile
209171import Text.Pandoc.Writers.ZimWiki
210172import Text.Parsec.Error
211173
212−data Reader m = StringReader (ReaderOptions -> String -> m Pandoc)
213− | ByteStringReader (ReaderOptions -> BL.ByteString -> m Pandoc)
214−
215−-- | Association list of formats and readers.
216−readers :: PandocMonad m => [(String, Reader m)]
217−readers = [ ("native" , StringReader readNative)
218− ,("json" , StringReader $ \o s ->
219− case readJSON o s of
220− Right doc -> return doc
221− Left _ -> throwError $ PandocParseError "JSON parse error")
222− ,("markdown" , StringReader readMarkdown)
223− ,("markdown_strict" , StringReader readMarkdown)
224− ,("markdown_phpextra" , StringReader readMarkdown)
225− ,("markdown_github" , StringReader readMarkdown)
226− ,("markdown_mmd", StringReader readMarkdown)
227− ,("commonmark" , StringReader readCommonMark)
228− ,("rst" , StringReader readRST)
229− ,("mediawiki" , StringReader readMediaWiki)
230− ,("docbook" , StringReader readDocBook)
231− ,("opml" , StringReader readOPML)
232− ,("org" , StringReader readOrg)
233− ,("textile" , StringReader readTextile) -- TODO : textile+lhs
234− ,("html" , StringReader readHtml)
235− ,("latex" , StringReader readLaTeX)
236− ,("haddock" , StringReader readHaddock)
237− ,("twiki" , StringReader readTWiki)
238− ,("docx" , ByteStringReader readDocx)
239− ,("odt" , ByteStringReader readOdt)
240− ,("t2t" , StringReader readTxt2Tags)
241− ,("epub" , ByteStringReader readEPUB)
242− ]
243−
244174data Writer m = StringWriter (WriterOptions -> Pandoc -> m String)
245175 | ByteStringWriter (WriterOptions -> Pandoc -> m BL.ByteString)
246176
@@ -296,21 +226,6 @@ writers = [
296226 ,("muse" , StringWriter writeMuse)
297227 ]
298228
299−-- | Retrieve reader based on formatSpec (format+extensions).
300−getReader :: PandocMonad m => String -> Either String (Reader m)
301−getReader s =
302− case parseFormatSpec s of
303− Left e -> Left $ intercalate "\n" [m | Message m <- errorMessages e]
304− Right (readerName, setExts) ->
305− case lookup readerName readers of
306− Nothing -> Left $ "Unknown reader: " ++ readerName
307− Just (StringReader r) -> Right $ StringReader $ \o ->
308− r o{ readerExtensions = setExts $
309− getDefaultExtensions readerName }
310− Just (ByteStringReader r) -> Right $ ByteStringReader $ \o ->
311− r o{ readerExtensions = setExts $
312− getDefaultExtensions readerName }
313−
314229getWriter :: PandocMonad m => String -> Either String (Writer m)
315230getWriter s
316231 = case parseFormatSpec s of
@@ -325,8 +240,5 @@ getWriter s
325240 \o -> r o{ writerExtensions = setExts $
326241 getDefaultExtensions writerName }
327242
328−readJSON :: ReaderOptions -> String -> Either PandocError Pandoc
329−readJSON _ = mapLeft PandocParseError . eitherDecode' . UTF8.fromStringLazy
330−
331243writeJSON :: WriterOptions -> Pandoc -> String
332244writeJSON _ = UTF8.toStringLazy . encode