Populate mediabag after filters have run. (#8114)

The mediabag is filled with document resources after the filters have
run. This allows, for example, filter authors to modify image paths
before pandoc tries to fetch the images.

Lua filters that rely on a filled mediabag can use the new
`pandoc.mediabag.fill` function to perform that action in the filter.

Closes: #8099
This commit is contained in:
Albert Krewinkel 2022-07-28 19:50:00 +02:00 committed by GitHub
parent 4ba72aaa2e
commit aaf69044b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -306,17 +306,16 @@ convertWithOpts opts = do
>>= r readerOpts >>= r readerOpts
ByteStringReader r -> ByteStringReader r ->
mconcat <$> mapM (r readerOpts . inputToLazyByteString) inputs) mconcat <$> mapM (r readerOpts . inputToLazyByteString) inputs)
>>= >>= ( return . adjustMetadata (metadataFromFile <>)
( (if not (optSandbox opts) &&
(isJust (optExtractMedia opts)
|| writerNameBase == "docx") -- for fallback pngs
then fillMediaBag
else return)
>=> return . adjustMetadata (metadataFromFile <>)
>=> return . adjustMetadata (<> optMetadata opts) >=> return . adjustMetadata (<> optMetadata opts)
>=> return . adjustMetadata (<> cslMetadata) >=> return . adjustMetadata (<> cslMetadata)
>=> applyTransforms transforms >=> applyTransforms transforms
>=> applyFilters filterEnv filters [T.unpack format] >=> applyFilters filterEnv filters [T.unpack format]
>=> (if not (optSandbox opts) &&
(isJust (optExtractMedia opts)
|| writerNameBase == "docx") -- for fallback pngs
then fillMediaBag
else return)
>=> maybe return extractMedia (optExtractMedia opts) >=> maybe return extractMedia (optExtractMedia opts)
) )