Don't incorporate externally linked images in EPUB documents (#7430)

Just like it is possible to avoid incorporating an image in EPUB by
passing `data-external="1"` to a raw HTML snippet, this makes the same
possible for native Images, by looking for an associated `external`
attribute.
This commit is contained in:
Michael Hoffmann 2021-07-07 18:26:37 +02:00 committed by GitHub
parent e56e2b0e0b
commit 565330033a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -6177,6 +6177,12 @@ with the `src` attribute. For example:
</source>
</audio>
If the input format already is HTML then `data-external="1"` will work
as expected for `<img>` elements. Similarly, for Markdown, external
images can be declared with `![img](url){external=1}`. Note that this
only works for images; the other media elements have no native
representation in pandoc's AST and requires the use of raw HTML.
# Jupyter notebooks
When creating a [Jupyter notebook], pandoc will try to infer the

View file

@ -1131,7 +1131,8 @@ transformInline :: PandocMonad m
=> WriterOptions
-> Inline
-> E m Inline
transformInline _opts (Image attr lab (src,tit)) = do
transformInline _opts (Image attr@(_,_,kvs) lab (src,tit))
| isNothing (lookup "external" kvs) = do
newsrc <- modifyMediaRef $ T.unpack src
return $ Image attr lab ("../" <> newsrc, tit)
transformInline opts x@(Math t m)