aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/MediaBag.hs
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2019-02-16 13:35:16 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2019-05-29 23:18:44 +0200
commit5a82ecaaa19176afc24576fd80b91c9a529c2dcb (patch)
tree8c7d4fcca448419987f6327de80cdc71bc3efe87 /src/Text/Pandoc/MediaBag.hs
parent0a6a11cfabead239eab3baec065d8d6e95bb6447 (diff)
downloadpandoc-5a82ecaaa19176afc24576fd80b91c9a529c2dcb.tar.gz
pandoc.mediabag module: add function `delete`
Function `pandoc.mediabag.delete` allows to remove a single item of the given name from the media bag.
Diffstat (limited to 'src/Text/Pandoc/MediaBag.hs')
-rw-r--r--src/Text/Pandoc/MediaBag.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Text/Pandoc/MediaBag.hs b/src/Text/Pandoc/MediaBag.hs
index 94512b71d..bb6fc88ac 100644
--- a/src/Text/Pandoc/MediaBag.hs
+++ b/src/Text/Pandoc/MediaBag.hs
@@ -16,6 +16,7 @@ interface for interacting with it.
-}
module Text.Pandoc.MediaBag (
MediaBag,
+ deleteMedia,
lookupMedia,
insertMedia,
mediaDirectory,
@@ -41,6 +42,14 @@ newtype MediaBag = MediaBag (M.Map [String] (MimeType, BL.ByteString))
instance Show MediaBag where
show bag = "MediaBag " ++ show (mediaDirectory bag)
+-- | Delete a media item from a 'MediaBag', or do nothing if no item corresponds
+-- to the given path.
+deleteMedia :: FilePath -- ^ relative path and canonical name of resource
+ -> MediaBag
+ -> MediaBag
+deleteMedia fp (MediaBag mediamap) =
+ MediaBag $ M.delete (splitDirectories fp) mediamap
+
-- | Insert a media item into a 'MediaBag', replacing any existing
-- value with the same name.
insertMedia :: FilePath -- ^ relative path and canonical name of resource