diff options
| author | Albert Krewinkel <[email protected]> | 2022-06-07 12:38:56 +0200 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2022-08-02 20:09:14 -0700 |
| commit | 096863e0adf360b37334a3f8f81e704652b1706b (patch) | |
| tree | 626a9c52afdf8268605fbd7657263eee17f0fc3d /src | |
| parent | 516c827d613d6a9b1f2aaf18610125c3aae0a8ac (diff) | |
fillMediaBag: Keep attributes of original image on Span
Images that cannot be fetched are replaced with a Span that contains the
image's description. The span now also retains all original image
attributes and inherits all attributes of the image. Furthermore, the
classes `image` and `placeholder` are added, and path and title are
store in attributes `original-image-src` and `original-image-title`,
respectively.
Closes: #8099
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Class/PandocMonad.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Class/PandocMonad.hs b/src/Text/Pandoc/Class/PandocMonad.hs index 6660db286..e108dd13e 100644 --- a/src/Text/Pandoc/Class/PandocMonad.hs +++ b/src/Text/Pandoc/Class/PandocMonad.hs @@ -703,15 +703,24 @@ fillMediaBag d = walkM handleImage d report $ CouldNotFetchResource src "replacing image with description" -- emit alt text - return $ Span ("",["image"],[]) lab + return $ replacementSpan attr src tit lab PandocHttpError u er -> do report $ CouldNotFetchResource u (T.pack $ show er ++ "\rReplacing image with description.") -- emit alt text - return $ Span ("",["image"],[]) lab + return $ replacementSpan attr src tit lab _ -> throwError e) handleImage x = return x + replacementSpan (ident, classes, attribs) src title descr = + Span ( ident + , "image":"placeholder":classes + , ("original-image-src", src) : + ("original-image-title", title) : + attribs + ) + descr + -- This requires UndecidableInstances. We could avoid that -- by repeating the definitions below for every monad transformer -- we use: ReaderT, WriterT, StateT, RWST. But this seems to |
