Text.Pandoc.MediaBag

pandoc-1.16.0.2: Conversion between markup formats

Copyright | Copyright (C) 2014 John MacFarlane
License | GNU GPL, version 2 or above
Maintainer | John MacFarlane <jgm@berkeley.edu>
Stability | alpha
Portability | portable
Safe Haskell | None
Language | Haskell98

Text.Pandoc.MediaBag

Description

Definition of a MediaBag object to hold binary resources, and an interface for interacting with it.

Synopsis

- data MediaBag
- lookupMedia :: FilePath -> MediaBag -> Maybe (MimeType, ByteString)
- insertMedia :: FilePath -> Maybe MimeType -> ByteString -> MediaBag -> MediaBag
- mediaDirectory :: MediaBag -> [(String, MimeType, Int)]
- extractMediaBag :: Bool -> FilePath -> MediaBag -> IO ()

# Documentation

data MediaBag

A container for a collection of binary resources, with names and mime types. Note that a `MediaBag` is a Monoid, so `mempty` can be used for an empty `MediaBag`, and `<>` can be used to append two `MediaBag`s.

Instances

Data MediaBag |
Show MediaBag |
Monoid MediaBag |

lookupMedia :: FilePath -> MediaBag -> Maybe (MimeType, ByteString)

Lookup a media item in a `MediaBag`, returning mime type and contents.

insertMedia

Arguments

:: FilePath | relative path and canonical name of resource
-> Maybe MimeType | mime type (Nothing = determine from extension)
-> ByteString | contents of resource
-> MediaBag |
-> MediaBag |

Insert a media item into a `MediaBag`, replacing any existing value with the same name.

mediaDirectory :: MediaBag -> [(String, MimeType, Int)]

Get a list of the file paths stored in a `MediaBag`, with their corresponding mime types and the lengths in bytes of the contents.

extractMediaBag :: Bool -> FilePath -> MediaBag -> IO ()

Extract contents of MediaBag to a given directory. Print informational messages if `verbose` is true.