git.iko.soy/typeable/pandoc
on master help sign in
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: <audio controls="1"> <source src="http://www.sixbarsjail.it/tmp/bach_toccata.mp3" type="audio/mpeg"></source> </audio> Closes #2473.

commitc80c0df1fef118d32118dce222b204ae1f7b7f8b authorJohn MacFarlane <jgm@berkeley.edu> dateThu 12 Nov 2015, 13:27 (11 years ago) parent83b1aa0
2 files changed+20−2
README+18−1 src/Text/Pandoc/Writers/EPUB.hs+2−1
README+18−1
@@ -3489,8 +3489,11 @@ the [Beamer User's Guide] may also be used: `allowdisplaybreaks`,
34893489`allowframebreaks`, `b`, `c`, `t`, `environment`, `label`, `plain`,
34903490`shrink`.
34913491
3492+Creating EPUBs with pandoc
3493+==========================
3494+
34923495EPUB Metadata
3493−=============
3496+-------------
34943497
34953498EPUB metadata may be specified using the `--epub-metadata` option, but
34963499if the source document is markdown, it is better to use a [YAML metadata
@@ -3580,6 +3583,20 @@ The following fields are recognized:
35803583[MARC relators]: http://loc.gov/marc/relators/relaterm.html
35813584[`spine` element]: http://idpf.org/epub/301/spec/epub-publications.html#sec-spine-elem
35823585
3586+Linked media
3587+------------
3588+
3589+By default, pandoc will download linked media (including audio and
3590+video) and include it in the EPUB container, yielding a completely
3591+self-contained EPUB. If you want to link to external media resources
3592+instead, use raw HTML in your source and add `data-external="1"` to the tag
3593+with the `src` attribute. For example:
3594+
3595+ <audio controls="1">
3596+ <source src="http://www.sixbarsjail.it/tmp/bach_toccata.mp3"
3597+ data-external="1" type="audio/mpeg"></source>
3598+ </audio>
3599+
35833600Literate Haskell support
35843601========================
35853602
src/Text/Pandoc/Writers/EPUB.hs+2−1
@@ -816,7 +816,8 @@ transformTag :: WriterOptions
816816 -> Tag String
817817 -> IO (Tag String)
818818transformTag opts mediaRef tag@(TagOpen name attr)
819− | name `elem` ["video", "source", "img", "audio"] = do
819+ | name `elem` ["video", "source", "img", "audio"] &&
820+ lookup "data-external" attr == Nothing = do
820821 let src = fromAttrib "src" tag
821822 let poster = fromAttrib "poster" tag
822823 newsrc <- modifyMediaRef opts mediaRef src