-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Labels
Description
Explain the problem.
The LaTeX writer relies on the path extension of an image to determine whether to use \includegraphics or \includesvg:
pandoc/src/Text/Pandoc/Writers/LaTeX.hs
Line 1125 in ba04a99
| ((if isSVG then "\\includesvg" else "\\includegraphics") <> |
This breaks in instances where the URI of an image does not reference .svg. Consider, for instance, the following image:
Passing this to pandoc yields an error:
$ echo '' | pandoc -o test.pdf
[WARNING] Could not convert image /private/var/folders/_n/dwfw0_316w554fyv3q9t7m1w0000gn/T/tex2pdf.-7a6e25991b71d6c9/6e49fa4c4ffe43659ba3f4187ea0145ff5768d7a.yml: Cannot load file
Jpeg Invalid marker used
PNG Invalid PNG file, signature broken
Bitmap Invalid Bitmap magic identifier
GIF Invalid Gif signature : <svg x
HDR Invalid radiance file signature
Tiff Invalid endian tag value
TGA not enough bytes
Error producing PDF.
! LaTeX Error: Unknown graphics extension: .yml.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.69 ...fa4c4ffe43659ba3f4187ea0145ff5768d7a.yml}}Relevant code and possible solutions:
- When the image is added to the media bag, the
.ymlextension is preferred over the mimetype.
pandoc/src/Text/Pandoc/MediaBag.hs
Lines 110 to 112 in ba04a99
ext = case takeExtension path of '.':e | '%' `notElem` e -> '.':e _ -> maybe "" (\x -> '.':T.unpack x) $ extensionFromMimeType mt
For remote images, this could be changed to prefer mimetype over any extension contained in the URI, at least if the extension in the URI does not correspond to an image. Then, the image would be stored as...8d7a.svgand the extension check would be sufficient. - The LaTeX writer could check the mimetype of the image in the mediabag instead of checking the extension of the URI:
pandoc/src/Text/Pandoc/Writers/LaTeX.hs
Line 1082 in ba04a99
let isSVG = ".svg" `T.isSuffixOf` source || ".SVG" `T.isSuffixOf` source
Pandoc version?
pandoc 3.6.1 MacOS