-
Notifications
You must be signed in to change notification settings - Fork 924
[Feature request] Add img_alias_limit #1646
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
Comments
Additional: Another tool that can help reduce errors when migrating from other document builders to vuepress or adding vuepress builders from existing documents.
(code TODO: unpolished, the situation of the public folder was not considered) |
I think you should add this function to core, while adding a new option called |
Document supplement after the completion of this PR #1647 : (I'll write the document here for now. Once the PR is completed, I'll copy it over to the document side.) Option(add to: https://vuepress.github.io/zh/reference/config.html#markdown-assets) How to disable/limit url aliases、Usage(add to: https://vuepress.github.io/zh/guide/assets.html#base-helper)
const userConfig: UserConfig = {
markdown: {
assets: {
aliasSupport: '@-perfix'
}
}
} |
Clear and concise description of the problem
Leading factors
Due to the alias mechanism of vuepress: https://vuejs.press/zh/guide/assets.html
vuepress extends the behavior of
<img src="urls not beginning with ./ or/"
, overwriting the syntax of md and causing syntax conflicts. That is, only looking at md and not vuepress, this way of writing is completely legal and compliant. And this will cause some problems.Environment and Demand
On this basis, many blog posts by writers who do not use vuepress do not notice this point. They might have been using other file builders (such as gitbook, cookbook, vitepress, mdbook) before this. Or perhaps they haven't started using the document builder, but have already written quite a lot of md content.
In these environments (other md document builders and markdown local editors), the situation where
img src
is not prefixed with./
or/
exists in large numbers.A typical case is that I often deploy some online documents, and these documents might be written by others. They might not have used the document builder before or used other document builders.
Then in the past, during the deployment process (following the open-source license), I modified the original document a lot due to compilation errors (yes, I don't want to do this anymore, and it's very difficult for me to convince others to accept this kind of PR where I added
./
because the original content is completely legal), and found that this writing style is widespread (I have encountered five document repositories because this one cannot be compiled and needs to be modified).As for why they don't use it
![]()
, might be because you want to add attr/class/attr/style/size, etc. Perhaps it is because it is used in some html fragments (such as<detail>
)Suggested solution
I can make a PR if the FR is approved.
Consider adding the function to:https://ecosystem.vuejs.press/plugins/markdown/markdown-image.html
Note that I have retained the function of using aliases when '@' is used as a prefix, and this will not reduce the original function. It is said that previously, the alias of vitepress had to start with
~
, so this situation will not occurcode: (straight-ahead)
Alternative
No response
Additional context
The code for handling the corresponding logic in vuepress
core/packages/markdown/src/markdown.ts
Line 84 in a78ee55
core/packages/markdown/src/plugins/assetsPlugin/assetsPlugin.ts
Line 40 in a78ee55
The text was updated successfully, but these errors were encountered: