Skip to content

[Feature request] Add img_alias_limit #1646

Open
@LincZero

Description

@LincZero

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 occur

code: (straight-ahead)

Image

Alternative

No response

Additional context

The code for handling the corresponding logic in vuepress

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions