From 36449d3ea4708009e474507de27077c1b936adad Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 7 Nov 2017 08:30:52 -0800 Subject: EPUB writer: fix image paths with empty `--epub-subdirectory`. --- src/Text/Pandoc/Writers/EPUB.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Writers/EPUB.hs') 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 -- cgit v1.2.3