marp-team / marp-vscode

Marp for VS Code: Create slide deck written in Marp Markdown on VS Code
https://marketplace.visualstudio.com/items?itemName=marp-team.marp-vscode
MIT License
1.58k stars 74 forks source link

the keyword bg is not working in marp for vscode #417

Closed GritYolo closed 1 year ago

GritYolo commented 1 year ago

when i use marp in my vscode, the picture will disappear when i use 'bg' keword ,such as : ![bg](/assets/1.png)

if it is: ![](/assets/1.png)

the picture will enmergence

yhatt commented 1 year ago

TL;DR: Try using the relative path from Markdown file, ![bg](./assets/1.png) or ![bg](assets/1.png), instead of the absolute path ![bg](/assets/1.png).

Resolving absolute path is context-aware and unstable. We always recommend to use relative paths. e.g. Even if using ![](), /assets/1.png cannot render an image, when opening Markdown without workspace.

When rendering the preview of Markdown that is located in workspace, VS Code tries manipulating image paths specified in the regular Markdown images. For example, `/assets/1.png` will convert to `https://file+.vscode-resource.vscode-cdn.net/xxx/xxxx/xxx/assets/1.png` (`/xxx/xxxx/xxx` is the path for current workspace). This URL is virtual path, and required to render images in the preview panel correctly. `![bg]()` syntax is Marp specific and not covered by VS Code's Markdown preview. So paths for background images will not manipulate. `/assets/1.png` will become `url('/assets/1.png')`.
GritYolo commented 1 year ago

thank you !it works!