ipynb writer: don't create attachments for images with absolute URIs.

...including data: URIs.

Closes #5303.
This commit is contained in:
John MacFarlane 2019-02-15 22:55:17 -08:00
parent d7d1c9c8e4
commit bc2aca3d6d

View file

@ -49,7 +49,7 @@ import Data.Text (Text)
import qualified Data.Text as T
import Data.Aeson as Aeson
import qualified Text.Pandoc.UTF8 as UTF8
import Text.Pandoc.Shared (safeRead)
import Text.Pandoc.Shared (safeRead, isURI)
import Text.Pandoc.Writers.Shared (metaToJSON')
import Text.Pandoc.Writers.Markdown (writeMarkdown)
import qualified Data.Text.Encoding as TE
@ -98,7 +98,8 @@ pandocToNotebook opts (Pandoc meta blocks) = do
addAttachment :: PandocMonad m
=> Inline
-> StateT (M.Map Text MimeBundle) m Inline
addAttachment (Image attr lab (src,tit)) = do
addAttachment (Image attr lab (src,tit))
| not (isURI src) = do
(img, mbmt) <- fetchItem src
let mt = maybe "application/octet-stream" (T.pack) mbmt
modify $ M.insert (T.pack src)