@@ -1353,6 +1353,48 @@ convertWithOpts opts args = do
1353 , readerFileScope = fileScope
1353 , readerFileScope = fileScope
1356+ let writerOptions = def { writerTemplate = templ,
1357+ writerVariables = variables'',
1358+ writerTabStop = tabStop,
1359+ writerTableOfContents = toc,
1360+ writerHTMLMathMethod = mathMethod,
1361+ writerIncremental = incremental,
1362+ writerCiteMethod = citeMethod,
1363+ writerIgnoreNotes = False,
1364+ writerNumberSections = numberSections,
1365+ writerNumberOffset = numberFrom,
1366+ writerSectionDivs = sectionDivs,
1367+ writerReferenceLinks = referenceLinks,
1368+ writerReferenceLocation = referenceLocation,
1370+ writerWrapText = wrap,
1371+ writerColumns = columns,
1372+ writerEmailObfuscation = obfuscationMethod,
1373+ writerIdentifierPrefix = idPrefix,
1374+ writerSourceURL = sourceURL,
1375+ writerUserDataDir = datadir,
1376+ writerHtml5 = html5,
1377+ writerHtmlQTags = htmlQTags,
1378+ writerTopLevelDivision = topLevelDivision,
1379+ writerListings = listings,
1380+ writerBeamer = False,
1381+ writerSlideLevel = slideLevel,
1382+ writerHighlight = highlight,
1383+ writerHighlightStyle = highlightStyle,
1384+ writerSetextHeaders = setextHeaders,
1385+ writerTeXLigatures = texLigatures,
1386+ writerEpubMetadata = epubMetadata,
1387+ writerEpubStylesheet = epubStylesheet,
1388+ writerEpubFonts = epubFonts,
1389+ writerEpubChapterLevel = epubChapterLevel,
1390+ writerTOCDepth = epubTOCDepth,
1391+ writerReferenceDoc = referenceDoc,
1392+ writerMediaBag = mempty,
1393+ writerVerbose = verbose,
1394+ writerLaTeXArgs = latexEngineArgs
1356#ifdef _WINDOWS
1398#ifdef _WINDOWS
1357 let istty = True
1399 let istty = True
@@ -1426,47 +1468,6 @@ convertWithOpts opts args = do
1426 _ -> do pairs <- mapM (\s -> sourceToDoc [s]) sources
1468 _ -> do pairs <- mapM (\s -> sourceToDoc [s]) sources
1427 return (mconcat $ map fst pairs, mconcat $ map snd pairs)
1469 return (mconcat $ map fst pairs, mconcat $ map snd pairs)
1429− let writerOptions = def { writerTemplate = templ,
1430− writerVariables = variables'',
1431− writerTabStop = tabStop,
1432− writerTableOfContents = toc,
1433− writerHTMLMathMethod = mathMethod,
1434− writerIncremental = incremental,
1435− writerCiteMethod = citeMethod,
1436− writerIgnoreNotes = False,
1437− writerNumberSections = numberSections,
1438− writerNumberOffset = numberFrom,
1439− writerSectionDivs = sectionDivs,
1440− writerReferenceLinks = referenceLinks,
1441− writerReferenceLocation = referenceLocation,
1443− writerWrapText = wrap,
1444− writerColumns = columns,
1445− writerEmailObfuscation = obfuscationMethod,
1446− writerIdentifierPrefix = idPrefix,
1447− writerSourceURL = sourceURL,
1448− writerUserDataDir = datadir,
1449− writerHtml5 = html5,
1450− writerHtmlQTags = htmlQTags,
1451− writerTopLevelDivision = topLevelDivision,
1452− writerListings = listings,
1453− writerBeamer = False,
1454− writerSlideLevel = slideLevel,
1455− writerHighlight = highlight,
1456− writerHighlightStyle = highlightStyle,
1457− writerSetextHeaders = setextHeaders,
1458− writerTeXLigatures = texLigatures,
1459− writerEpubMetadata = epubMetadata,
1460− writerEpubStylesheet = epubStylesheet,
1461− writerEpubFonts = epubFonts,
1462− writerEpubChapterLevel = epubChapterLevel,
1463− writerTOCDepth = epubTOCDepth,
1464− writerReferenceDoc = referenceDoc,
1465− writerMediaBag = media,
1466− writerVerbose = verbose,
1467− writerLaTeXArgs = latexEngineArgs
1471 doc' <- (maybe return (extractMedia media) mbExtractMedia >=>
1472 doc' <- (maybe return (extractMedia media) mbExtractMedia >=>
1472 adjustMetadata metadata >=>
1473 adjustMetadata metadata >=>
@@ -1481,9 +1482,10 @@ convertWithOpts opts args = do
1481 writerFn "-" = UTF8.putStr
1482 writerFn "-" = UTF8.putStr
1482 writerFn f = UTF8.writeFile f
1483 writerFn f = UTF8.writeFile f
1485+ let writerOptions' = writerOptions{ writerMediaBag = media }
1484 case writer of
1486 case writer of
1485 -- StringWriter f -> f writerOptions doc' >>= writerFn outputFile
1487 -- StringWriter f -> f writerOptions doc' >>= writerFn outputFile
1486− ByteStringWriter f -> (runIO' $ f writerOptions doc')
1488+ ByteStringWriter f -> (runIO' $ f writerOptions' doc')
1487 >>= writeFnBinary outputFile
1489 >>= writeFnBinary outputFile
1488 StringWriter f
1490 StringWriter f
1489 | pdfOutput -> do
1491 | pdfOutput -> do
@@ -1502,7 +1504,7 @@ convertWithOpts opts args = do
1502 err 41 $ pdfprog ++ " not found. " ++
1504 err 41 $ pdfprog ++ " not found. " ++
1503 pdfprog ++ " is needed for pdf output."
1505 pdfprog ++ " is needed for pdf output."
1505− res <- makePDF pdfprog f writerOptions doc'
1507+ res <- makePDF pdfprog f writerOptions' doc'
1506 case res of
1508 case res of
1507 Right pdf -> writeFnBinary outputFile pdf
1509 Right pdf -> writeFnBinary outputFile pdf
1508 Left err' -> do
1510 Left err' -> do
@@ -1513,10 +1515,10 @@ convertWithOpts opts args = do
1513 let htmlFormat = format `elem`
1515 let htmlFormat = format `elem`
1514 ["html","html5","s5","slidy","slideous","dzslides","revealjs"]
1516 ["html","html5","s5","slidy","slideous","dzslides","revealjs"]
1515 selfcontain = if selfContained && htmlFormat
1517 selfcontain = if selfContained && htmlFormat
1516− then makeSelfContained writerOptions
1518+ then makeSelfContained writerOptions'
1517 else return
1519 else return
1518 handleEntities = if htmlFormat && ascii
1520 handleEntities = if htmlFormat && ascii
1519 then toEntities
1521 then toEntities
1521− output <- runIO' $ f writerOptions doc'
1523+ output <- runIO' $ f writerOptions' doc'
1522 selfcontain (output ++ ['\n' | not standalone']) >>= writerFn outputFile . handleEntities
1524 selfcontain (output ++ ['\n' | not standalone']) >>= writerFn outputFile . handleEntities