Closed lep closed 7 years ago
Ok, i have managed to compile pandoc from source:
$ git show-ref HEAD --abbrev=6
d8600d
$ ./dist/build/pandoc/pandoc --version
1.17.3
<snip>
$ ./dist/build/pandoc/pandoc -o failing.pdf failing.epub
pandoc: Could not find image `Text/data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=', skipping...
pandoc: Could not find image `Text/data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAARSURBVBhXY3gro4KMGCjkAwCr9R1miWOjyQAAAABJRU5ErkJggg==', skipping...
As you can see the pdf builds now but the images are being ignored. So i guess that's okay-ish but if someone wants to investigate it's still the same testcase as above.
This patch seems to do the trick for me but i have not compiled pandoc with tests enabled.
diff --git a/src/Text/Pandoc/Readers/EPUB.hs b/src/Text/Pandoc/Readers/EPUB.hs
index e547b84..ecbfa0b 100644
--- a/src/Text/Pandoc/Readers/EPUB.hs
+++ b/src/Text/Pandoc/Readers/EPUB.hs
@@ -109,7 +109,9 @@ iq _ = []
-- Remove relative paths
renameImages :: FilePath -> Inline -> Inline
-renameImages root (Image attr a (url, b)) = Image attr a (collapseFilePath (root </> url), b)
+renameImages root img@(Image attr a (url, b))
+ | "data:image" `isPrefixOf` url = img
+ | otherwise = Image attr a (collapseFilePath (root </> url), b)
renameImages _ x = x
imageToPandoc :: FilePath -> Pandoc
I try to convert some epubs to pdfs and some fail with the following error:
The issue is that if the epubs content is stored inside a directory like
Text/ch0001.xhtml
pandoc will, when it encounters some base64-inlined image, prefix that URI withText/
which obviously doesn't exist.I have attached two files as a zip, a working and a failing epub-file epubs.zip