aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2020-06-09 09:41:34 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2020-06-09 09:41:34 -0700
commit8d07940828877902b34642a66d2581d504d1adea (patch)
treecb302c408cfa8b84887e6904711ecfa8773cc4eb
parenta71278b83ef6ae27aec303a64f82899d4ac199b5 (diff)
downloadpandoc-8d07940828877902b34642a66d2581d504d1adea.tar.gz
Ipynb reader: properly handle image/svg+xml as an image.
Partially addresses #6430.
-rw-r--r--src/Text/Pandoc/Readers/Ipynb.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/Ipynb.hs b/src/Text/Pandoc/Readers/Ipynb.hs
index 079eacf97..521f47417 100644
--- a/src/Text/Pandoc/Readers/Ipynb.hs
+++ b/src/Text/Pandoc/Readers/Ipynb.hs
@@ -156,7 +156,7 @@ handleData metadata (MimeBundle mb) =
where
dataBlock :: PandocMonad m => (MimeType, MimeData) -> m B.Blocks
- dataBlock (mt, BinaryData bs)
+ dataBlock (mt, d)
| "image/" `T.isPrefixOf` mt
= do
-- normally metadata maps from mime types to key-value map;
@@ -168,7 +168,10 @@ handleData metadata (MimeBundle mb) =
Error _ -> mempty
_ -> mempty
let metaPairs = jsonMetaToPairs meta
- let bl = BL.fromStrict bs
+ let bl = case d of
+ BinaryData bs -> BL.fromStrict bs
+ TextualData t -> BL.fromStrict $ UTF8.fromText t
+ JsonData v -> encode v
-- SHA1 hash for filename
let fname = T.pack (showDigest (sha1 bl)) <>
case extensionFromMimeType mt of
@@ -176,7 +179,6 @@ handleData metadata (MimeBundle mb) =
Just ext -> "." <> ext
insertMedia (T.unpack fname) (Just mt) bl
return $ B.para $ B.imageWith ("",[],metaPairs) fname "" mempty
- | otherwise = return mempty
dataBlock ("text/html", TextualData t)
= return $ B.rawBlock "html" t