@@ -76,7 +76,12 @@ instance Show ImageMode where
7676writeFB2 :: WriterOptions -- ^ conversion options
7777 -> Pandoc -- ^ document to convert
7878 -> IO String -- ^ FictionBook2 document (not encoded yet)
79−writeFB2 opts (Pandoc meta blocks) = flip evalStateT newFB $ do
79+writeFB2 opts doc = flip evalStateT newFB $ pandocToFB2 opts doc
80+
81+pandocToFB2 :: WriterOptions
82+ -> Pandoc
83+ -> FBM String
84+pandocToFB2 opts (Pandoc meta blocks) = do
8085 modify (\s -> s { writerOptions = opts { writerStandalone = True } })
8186 desc <- description meta
8287 fp <- frontpage meta
@@ -95,7 +100,6 @@ writeFB2 opts (Pandoc meta blocks) = flip evalStateT newFB $ do
95100 in [ uattr "xmlns" xmlns
96101 , attr ("xmlns", "l") xlink ]
97102
98−
99103frontpage :: Meta -> FBM [Content]
100104frontpage meta' = do
101105 t <- cMapM toXml . docTitle $ meta'
@@ -250,11 +254,13 @@ fetchImage href link = do
250254 , uattr "content-type" imgtype]
251255 , txt imgdata )
252256 _ -> return (Left ('#':href))
253− where
254− nothingOnError :: (IO B.ByteString) -> (IO (Maybe B.ByteString))
255− nothingOnError action = liftM Just action `E.catch` omnihandler
256− omnihandler :: E.SomeException -> IO (Maybe B.ByteString)
257− omnihandler _ = return Nothing
257+
258+
259+nothingOnError :: (IO B.ByteString) -> (IO (Maybe B.ByteString))
260+nothingOnError action = liftM Just action `E.catch` omnihandler
261+
262+omnihandler :: E.SomeException -> IO (Maybe B.ByteString)
263+omnihandler _ = return Nothing
258264
259265-- | Extract mime type and encoded data from the Data URI.
260266readDataURI :: String -- ^ URI