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

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

Open
Mister-Hope opened this issue Jul 3, 2024 · 3 comments · May be fixed by #1606

Comments

@Mister-Hope
Copy link
Member

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
Copy link
Member Author

@meteorlxy

@Mister-Hope
Copy link
Member Author

@meteorlxy Reping

@meteorlxy
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants