core icon indicating copy to clipboard operation
core copied to clipboard

[Feature request] Recognize @source and maybe treat all @ started path as alias with markdown image

Open Mister-Hope opened this issue 1 year ago • 3 comments

Clear and concise description of the problem

Some people may want to reference image from root, but in our latest changes, the markdown image syntax no longer supports alias.

![](a/b.jpg) is regarded as <img src="./a/b.jpg" /> even if a is a package name or valid alias.

This is more expected as a/b.jpg will be a relative path in most cases instead a path that need to be resolved with bundler.

Also, we provided backwards ability, that in case people want to use alias or package imports, they can use img tag:

<img src="a/b.jpg" /> will be ./b.jpg exports in package a.

But we internally support @source for src folder, and when users want to reference images in projects folder instead of public (in most cases people are using i18n, and a image is placed at root language, and they want to make the link constant in all languages like @source/guide/example.png)

Suggested solution

We'd better check whether a markdown image link is started with @source/ , to avoid a @source/a.jpg being parsed as @source/folder/@source/a.jpg from @source/folder/file.md.

And we may even treat all links started with @ as alias. This is more flexible that allows markdown image be default as relative links but still supports alias.

Alternative

No response

Additional context

No response

Mister-Hope avatar Jul 03 '24 03:07 Mister-Hope

@meteorlxy

Mister-Hope avatar Jul 03 '24 03:07 Mister-Hope

@meteorlxy Reping

Mister-Hope avatar Jul 13 '24 13:07 Mister-Hope

@source is an internal shim, cuz we are generating temp files from source files. Ideally we should remove the shim, allowing relative image reference from markdown directly.

meteorlxy avatar Jul 25 '24 02:07 meteorlxy