Skip to content
Browse files

writeFB2 moved to a new list of writers which require IO.

  • Loading branch information...
1 parent 09257d1 commit 35c2f4bfaef74658c73210cb16e1b0f0eff5d2bb @astanin committed
Showing with 17 additions and 5 deletions.
  1. +7 −0 src/Text/Pandoc.hs
  2. +10 −5 src/pandoc.hs
View
7 src/Text/Pandoc.hs
@@ -63,6 +63,7 @@ module Text.Pandoc
-- * Lists of readers and writers
, readers
, writers
+ , iowriters
-- * Readers: converting /to/ Pandoc format
, readMarkdown
, readRST
@@ -214,6 +215,12 @@ writers = [("native" , writeNative)
,("fb2" , writeFB2)
]
+-- | Association list of formats and writers which require IO to work.
+-- These writers produce text output as well as thoses in 'writers'.
+iowriters :: [ (String, WriterOptions -> Pandoc -> IO String) ]
+iowriters = [ ("fb2" , writeFB2)
+ ]
+
{-# DEPRECATED jsonFilter "Use toJsonFilter instead" #-}
-- | Converts a transformation on the Pandoc AST into a function
-- that reads and writes a JSON-encoded string. This is useful
View
15 src/pandoc.hs
@@ -55,7 +55,7 @@ import Control.Monad (when, unless, liftM)
import Network.HTTP (simpleHTTP, mkRequest, getResponseBody, RequestMethod(..))
import Network.URI (parseURI, isURI, URI(..))
import qualified Data.ByteString.Lazy as B
-import Data.ByteString.Lazy.UTF8 (toString, fromString)
+import Data.ByteString.Lazy.UTF8 (toString)
import Codec.Binary.UTF8.String (decodeString, encodeString)
import Text.CSL.Reference (Reference(..))
@@ -1017,8 +1017,13 @@ main = do
writerFn "-" = UTF8.putStr
writerFn f = UTF8.writeFile f
- case lookup writerName' writers of
- Nothing
+ let purewriter = lookup writerName' writers
+ let iowriter = lookup writerName' iowriters
+ case (purewriter, iowriter) of
+ (Nothing, Just iow) -> do
+ d <- iow writerOptions doc2
+ writerFn outputFile d
+ (Nothing, Nothing)
| writerName' == "epub" ->
writeEPUB epubStylesheet epubFonts writerOptions doc2
>>= writeBinary
@@ -1028,13 +1033,13 @@ main = do
writeDocx referenceDocx writerOptions doc2 >>= writeBinary
B.writeFile (encodeString outputFile) (fromString d)
| otherwise -> err 9 ("Unknown writer: " ++ writerName')
- Just w
+ (Just w, _)
| pdfOutput -> do
res <- tex2pdf latexEngine $ w writerOptions doc2
case res of
Right pdf -> writeBinary pdf
Left err' -> err 43 $ toString err'
- Just w
+ (Just w, _)
| htmlFormat && ascii ->
writerFn outputFile =<< selfcontain (toEntities result)
| otherwise ->

0 comments on commit 35c2f4b

Please sign in to comment.
Something went wrong with that request. Please try again.