pandoc-3.1.13: Conversion between markup formats

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

Text.Pandoc.MediaBag

Description

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

Synopsis

- data MediaItem = MediaItem {
  - mediaMimeType :: MimeType
  - mediaPath :: FilePath
  - mediaContents :: ByteString
  }
- data MediaBag
- deleteMedia :: FilePath -> MediaBag -> MediaBag
- lookupMedia :: FilePath -> MediaBag -> Maybe MediaItem
- insertMedia :: FilePath -> Maybe MimeType -> ByteString -> MediaBag -> MediaBag
- mediaDirectory :: MediaBag -> [(FilePath, MimeType, Int)]
- mediaItems :: MediaBag -> [(FilePath, MimeType, ByteString)]

# Documentation

data MediaItem #

Constructors

MediaItem |
Fields mediaMimeType :: MimeType mediaPath :: FilePath mediaContents :: ByteString

#### Instances

Instances details

Data MediaItem # |
Instance details Defined in Text.Pandoc.MediaBag Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MediaItem -> c MediaItem # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c MediaItem # toConstr :: MediaItem -> Constr # dataTypeOf :: MediaItem -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c MediaItem) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MediaItem) # gmapT :: (forall b. Data b => b -> b) -> MediaItem -> MediaItem # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MediaItem -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MediaItem -> r # gmapQ :: (forall d. Data d => d -> u) -> MediaItem -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> MediaItem -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> MediaItem -> m MediaItem # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MediaItem -> m MediaItem # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MediaItem -> m MediaItem #
Show MediaItem # |
Instance details Defined in Text.Pandoc.MediaBag Methods showsPrec :: Int -> MediaItem -> ShowS # show :: MediaItem -> String # showList :: [MediaItem] -> ShowS #
Eq MediaItem # |
Instance details Defined in Text.Pandoc.MediaBag Methods (==) :: MediaItem -> MediaItem -> Bool # (/=) :: MediaItem -> MediaItem -> Bool #
Ord MediaItem # |
Instance details Defined in Text.Pandoc.MediaBag Methods compare :: MediaItem -> MediaItem -> Ordering # (<) :: MediaItem -> MediaItem -> Bool # (<=) :: MediaItem -> MediaItem -> Bool # (>) :: MediaItem -> MediaItem -> Bool # (>=) :: MediaItem -> MediaItem -> Bool # max :: MediaItem -> MediaItem -> MediaItem # min :: MediaItem -> MediaItem -> MediaItem #

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

Instances details

Data MediaBag # |
Instance details Defined in Text.Pandoc.MediaBag Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MediaBag -> c MediaBag # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c MediaBag # toConstr :: MediaBag -> Constr # dataTypeOf :: MediaBag -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c MediaBag) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MediaBag) # gmapT :: (forall b. Data b => b -> b) -> MediaBag -> MediaBag # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MediaBag -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MediaBag -> r # gmapQ :: (forall d. Data d => d -> u) -> MediaBag -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> MediaBag -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> MediaBag -> m MediaBag # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MediaBag -> m MediaBag # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MediaBag -> m MediaBag #
Monoid MediaBag # |
Instance details Defined in Text.Pandoc.MediaBag Methods mempty :: MediaBag # mappend :: MediaBag -> MediaBag -> MediaBag # mconcat :: [MediaBag] -> MediaBag #
Semigroup MediaBag # |
Instance details Defined in Text.Pandoc.MediaBag Methods (<>) :: MediaBag -> MediaBag -> MediaBag # sconcat :: NonEmpty MediaBag -> MediaBag # stimes :: Integral b => b -> MediaBag -> MediaBag #
Show MediaBag # |
Instance details Defined in Text.Pandoc.MediaBag Methods showsPrec :: Int -> MediaBag -> ShowS # show :: MediaBag -> String # showList :: [MediaBag] -> ShowS #

deleteMedia #

Arguments

:: FilePath | relative path and canonical name of resource
-> MediaBag |
-> MediaBag |

Delete a media item from a `MediaBag`, or do nothing if no item corresponds to the given path.

lookupMedia :: FilePath -> MediaBag -> Maybe MediaItem #

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 -> [(FilePath, 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.

mediaItems :: MediaBag -> [(FilePath, MimeType, ByteString)] #