summaryrefslogtreecommitdiff
path: root/pandoc.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-07-30 14:07:31 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-07-30 14:07:31 -0700
commit234652a4b87a22cd937bcccb8a42f6ea1552a0f7 (patch)
tree03cd219dd8ee01a0e36c710a25b9c9f6035fe4b3 /pandoc.hs
parent28321a18bfcf87e5a874ad86c0c7ec82ed3848e4 (diff)
PDF, Docx, EPUB, and ODT writers now automatically use MediaBag.
The MediaBag is thread through from the reader, with no need to extract to files.
Diffstat (limited to 'pandoc.hs')
-rw-r--r--pandoc.hs18
1 files changed, 10 insertions, 8 deletions
diff --git a/pandoc.hs b/pandoc.hs
index cfe20bd97..b1666d306 100644
--- a/pandoc.hs
+++ b/pandoc.hs
@@ -1222,21 +1222,23 @@ main = do
| src `elem` paths = Image lab (dir ++ "/" ++ src, tit)
adjustImagePath _ _ x = x
- (doc, writerOptions') <-
+ (doc, media) <-
case reader of
StringReader r-> do
inp <- readSources sources >>=
handleIncludes' . convertTabs . intercalate "\n"
d <- r readerOpts inp
- return (d, writerOptions)
+ return (d, M.empty)
ByteStringReader r -> do
(d, media) <- readFiles sources >>= r readerOpts
- case mbExtractMedia of
- Just dir | not (M.null media) -> do
- mapM_ (writeMedia dir) $ M.toList media
- let d' = walk (adjustImagePath dir (M.keys media)) d
- return (d', writerOptions{ writerMediaBag = media })
- _ -> return (d, writerOptions)
+ d' <- case mbExtractMedia of
+ Just dir | not (M.null media) -> do
+ mapM_ (writeMedia dir) $ M.toList media
+ return $ walk (adjustImagePath dir (M.keys media)) d
+ _ -> return d
+ return (d', media)
+
+ let writerOptions' = writerOptions{ writerMediaBag = media }
let doc0 = M.foldWithKey setMeta doc metadata
let doc1 = foldr ($) doc0 transforms