From c80c0df1fef118d32118dce222b204ae1f7b7f8b Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 12 Nov 2015 13:27:41 -0800 Subject: EPUB writer: don't download linked media when `data-external` attribute set. By default pandoc downloads all linked media and includes it in the EPUB container. This can be disabled by setting `data-external` on the tags linking to media that should not be downloaded. Example: Closes #2473. --- README | 19 ++++++++++++++++++- src/Text/Pandoc/Writers/EPUB.hs | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README b/README index d8953ed48..f11412b33 100644 --- a/README +++ b/README @@ -3489,8 +3489,11 @@ the [Beamer User's Guide] may also be used: `allowdisplaybreaks`, `allowframebreaks`, `b`, `c`, `t`, `environment`, `label`, `plain`, `shrink`. +Creating EPUBs with pandoc +========================== + EPUB Metadata -============= +------------- EPUB metadata may be specified using the `--epub-metadata` option, but if the source document is markdown, it is better to use a [YAML metadata @@ -3580,6 +3583,20 @@ The following fields are recognized: [MARC relators]: http://loc.gov/marc/relators/relaterm.html [`spine` element]: http://idpf.org/epub/301/spec/epub-publications.html#sec-spine-elem +Linked media +------------ + +By default, pandoc will download linked media (including audio and +video) and include it in the EPUB container, yielding a completely +self-contained EPUB. If you want to link to external media resources +instead, use raw HTML in your source and add `data-external="1"` to the tag +with the `src` attribute. For example: + + + Literate Haskell support ======================== diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 2843f8c74..42f3d5e57 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -816,7 +816,8 @@ transformTag :: WriterOptions -> Tag String -> IO (Tag String) transformTag opts mediaRef tag@(TagOpen name attr) - | name `elem` ["video", "source", "img", "audio"] = do + | name `elem` ["video", "source", "img", "audio"] && + lookup "data-external" attr == Nothing = do let src = fromAttrib "src" tag let poster = fromAttrib "poster" tag newsrc <- modifyMediaRef opts mediaRef src -- cgit v1.2.3