-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embedded SVG images do not work for DOCX output #9195
Comments
Can you upload an md file I can test with? I can see one potential issue already. At https://github.com/jgm/pandoc/blob/main/src/Text/Pandoc/Class/IO.hs#L124-L130 |
Of course. [edit] Added a line for the SVG file in the next comment. That SVG file is also shown correctly in DOCX.
|
I can confirm that a file with an svgz extension is put in media, but that its contents are not compressed. Changing that manually in the docx file allows it to display. So, we just need to figure out why that is happening. |
- Only treat as base64 if ';base64' is present. - Otherwise treat as UTF-8 (not 100% reliable but should cover most other cases). - Strip off ';base64' (or ';charset=...' or whatever) from mime type. This last change addresses #9195 (problems with data URIs in conversion to docx).
I've pushed a change that actually makes this work, but there's still a small problem to iron out -- we are still getting a .svgz extension. Otherwise everything is perfect. |
OK, I've fixed the .svgz issue too now. |
Explain the problem.
I'm trying to embed images into markdown using the
![caption](data:image/...;base64,...)
format.It seems that embedding an SVG image fails somehow when exporting to DOCX. Opening the DOCX file using Word gives
The picture can't be displayed
-error. If I save the SVG image as an external SVG file, and add it to markdown using![caption](file.svg)
, then that same SVG file will work as expected.I tried looking into the DOCX file and one thing I noticed (unzipping it) is that the corresponding
.svgz
file in the media folder is correct and can be opened by other programs like inkscape, chrome, etc.[edit] I should note that PNG images can be embedded without issue. Also, embedded SVG images do work when exporting to HTML. So it doesn't seem to me like a feature that isn't supported.
[edit] Maybe unrelated, but I'm not sure why the extension of all the SVG files are saved as
.svgz
files. A search on the internet seems to indicate it's a compressed version of SVG files, but they don't seem to be compressed. I noticed the same issue when converting embedded images in HTML to Markdown with the--extract-media
option. All extracted images are saved as.svgz
files, but the contents of those files are not compressed and they don't load in my Markdown editor unless I manually change all the extensions to.svg
.Pandoc version?
I'm using version 3.1.9 on Windows.
The text was updated successfully, but these errors were encountered: