git.iko.soy/typeable/pandoc
on master help sign in
pandoc: Thread media bag into WriterOptions.

This will make it available to docx and epub readers, etc., so we don't have to extract media to a directory when going from docx -> epub.

commit77aa72ec245e3f1918ac095697fb6e4a82484f36 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 30 Jul 2014, 13:20 (12 years ago) parent08e2498
1 file changed+14−12
pandoc.hs+14−12
pandoc.hs+14−12
@@ -1222,19 +1222,21 @@ main = do
12221222 | src `elem` paths = Image lab (dir ++ "/" ++ src, tit)
12231223 adjustImagePath _ _ x = x
12241224
1225− doc <- case reader of
1226− StringReader r->
1227− readSources sources >>=
1228− handleIncludes' . convertTabs . intercalate "\n" >>=
1229− r readerOpts
1225+ (doc, writerOptions') <-
1226+ case reader of
1227+ StringReader r-> do
1228+ inp <- readSources sources >>=
1229+ handleIncludes' . convertTabs . intercalate "\n"
1230+ d <- r readerOpts inp
1231+ return (d, writerOptions)
12301232 ByteStringReader r -> do
12311233 (d, media) <- readFiles sources >>= r readerOpts
12321234 case mbExtractMedia of
12331235 Just dir | not (M.null media) -> do
12341236 mapM_ (writeMedia dir) $ M.toList media
1235− return $ walk (adjustImagePath dir (M.keys media)) d
1236− _ -> return d
1237−
1237+ let d' = walk (adjustImagePath dir (M.keys media)) d
1238+ return (d', writerOptions{ writerMediaBag = media })
1239+ _ -> return (d, writerOptions)
12381240
12391241 let doc0 = M.foldWithKey setMeta doc metadata
12401242 let doc1 = foldr ($) doc0 transforms
@@ -1248,8 +1250,8 @@ main = do
12481250 writerFn f = UTF8.writeFile f
12491251
12501252 case writer of
1251− IOStringWriter f -> f writerOptions doc2 >>= writerFn outputFile
1252− IOByteStringWriter f -> f writerOptions doc2 >>= writeBinary
1253+ IOStringWriter f -> f writerOptions' doc2 >>= writerFn outputFile
1254+ IOByteStringWriter f -> f writerOptions' doc2 >>= writeBinary
12531255 PureStringWriter f
12541256 | pdfOutput -> do
12551257 -- make sure writer is latex or beamer
@@ -1263,14 +1265,14 @@ main = do
12631265 err 41 $ latexEngine ++ " not found. " ++
12641266 latexEngine ++ " is needed for pdf output."
12651267
1266− res <- makePDF latexEngine f writerOptions doc2
1268+ res <- makePDF latexEngine f writerOptions' doc2
12671269 case res of
12681270 Right pdf -> writeBinary pdf
12691271 Left err' -> do
12701272 B.hPutStr stderr $ err'
12711273 B.hPut stderr $ B.pack [10]
12721274 err 43 "Error producing PDF from TeX source"
1273− | otherwise -> selfcontain (f writerOptions doc2 ++
1275+ | otherwise -> selfcontain (f writerOptions' doc2 ++
12741276 ['\n' | not standalone'])
12751277 >>= writerFn outputFile . handleEntities
12761278 where htmlFormat = writerName' `elem`