aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-11-07 08:30:52 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2017-11-07 08:30:52 -0800
commit36449d3ea4708009e474507de27077c1b936adad (patch)
tree4a21d1ac558805a347f9d888141958c35f8f9632
parentdd2455cb0d08efb39c8717f75f8ba6847322c016 (diff)
downloadpandoc-36449d3ea4708009e474507de27077c1b936adad.tar.gz
EPUB writer: fix image paths with empty `--epub-subdirectory`.
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index 1129ac3f4..0dcef1d63 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -959,15 +959,21 @@ transformInline :: PandocMonad m
=> WriterOptions
-> Inline
-> E m Inline
-transformInline _opts (Image attr lab (src,tit)) = do
+transformInline opts (Image attr lab (src,tit)) = do
newsrc <- modifyMediaRef src
- return $ Image attr lab ("../" ++ newsrc, tit)
+ let pref = if null (writerEpubSubdirectory opts)
+ then ""
+ else "../"
+ return $ Image attr lab (pref ++ newsrc, tit)
transformInline opts (x@(Math t m))
| WebTeX url <- writerHTMLMathMethod opts = do
newsrc <- modifyMediaRef (url ++ urlEncode m)
let mathclass = if t == DisplayMath then "display" else "inline"
+ let pref = if null (writerEpubSubdirectory opts)
+ then ""
+ else "../"
return $ Span ("",["math",mathclass],[])
- [Image nullAttr [x] ("../" ++ newsrc, "")]
+ [Image nullAttr [x] (pref ++ newsrc, "")]
transformInline _opts (RawInline fmt raw)
| fmt == Format "html" = do
let tags = parseTags raw