Skip to content
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

Image does not get generated in exported pdf file #404

Closed
georgikoemdzhiev opened this issue Feb 8, 2023 · 2 comments
Closed

Image does not get generated in exported pdf file #404

georgikoemdzhiev opened this issue Feb 8, 2023 · 2 comments
Labels
question 🙅 Not issue, just a question (should post to Marp discussion)

Comments

@georgikoemdzhiev
Copy link

I have a local png image that I have put onto my slide using the following code:

---
theme: gaia
_class: lead
paginate: true
backgroundColor: #fff
marp: true
backgroundImage: url('https://marp.app/assets/hero-background.svg')
---

## Long-term approach proposal

Convert existing terraform infra into modules with parameters.
![](/assets/images/combined2.png)

The image renders fine in the preview window in VS:
image

However, when I export my desk using mark: Export my Slide Deck command, the slide I get in the pdf file does not have the image:
image

Here is the image I am using:
combined2

@yhatt yhatt transferred this issue from marp-team/marpit Feb 8, 2023
@yhatt
Copy link
Member

yhatt commented Feb 8, 2023

🚚 Transfered issue from Marpit framework to Marp for VS Code.

In VS Code preview, any resources which were specified in the absolute path will have a different resolution way from other Marp tools, due to the specifcation of the Markdown preview. (The export command also can regard as one of other tools because it's actually using Marp CLI in internal)

In common, ![](/assets/images/combined2.png) has an exactly same meaning as <img src="/assets/images/combined2.png" />, and regularlly that path points out a local file resolved from the root: file:///assets/images/combined2.png

On the other hand, the root of resources used for VS Code Markdown preview will become the root of VS Code workspace you'are opening. If you were opening /home/username/marp/markdown directory as a VS Code workspace, the preview can show an image located in /home/username/marp/markdown/assets/images/combined2.png with the described absolute path.

Solutions

Use relative path

A thinking about "workspace" is VS Code specific. For interoperability with other Marp tools, we recommend to use a relative path from Markdown file instead.

![](./assets/images/combined2.png)

Experimental markdown.marp.strictPathResolutionDuringExport option

If you want to stick to use absolute path from the workspace root, you can try to export with turning on an experimental markdown.marp.strictPathResolutionDuringExport setting from the extension preference too. It's useful for getting more consistent result between preview and export.

See details in #367.

This is still an experimental feature so may have some unexpected behaviors. Welcome your feedbacks :)

@yhatt yhatt added the question 🙅 Not issue, just a question (should post to Marp discussion) label Feb 8, 2023
@georgikoemdzhiev
Copy link
Author

Thank you very much for explaining what the issue was. I never tried to experiment with the path. That fixed the issue :)

Thank you for the awesome project! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question 🙅 Not issue, just a question (should post to Marp discussion)
Projects
None yet
Development

No branches or pull requests

2 participants