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

Explicit ids? #940

Open
xianghongai opened this issue Jun 14, 2022 · 16 comments
Open

Explicit ids? #940

xianghongai opened this issue Jun 14, 2022 · 16 comments

Comments

@xianghongai
Copy link

Clear and concise description of the problem

want to explicitly set the id attribute of headings from the Markdown document, for example to keep them consistent across translations.

Suggested solution

Alternative

No response

Additional context

No response

@xianghongai
Copy link
Author

## 插入图片示例 {#insert-image}
## Insert Image {#insert-image}

@Mister-Hope
Copy link
Member

I do think about supporting it, currectly our logic is to apply a default slugify function on title.

@meteorlxy Any suggestion with this one?

@meteorlxy
Copy link
Member

meteorlxy commented Jun 14, 2022

I've noticed this before in some docs translation repo. I think users could use it with extendsMarkdown by themselves as needed.

Might be a good idea to integrate it by default.

@Mister-Hope
Copy link
Member

I've noticed this before in some docs translation repo. I think users could use it with extendsMarkdown by themselves as needed.

Nope, I think that's hard. I was trying to build one long time ago, but I met some issues.

@Mister-Hope
Copy link
Member

Anyway I will relook into this, and if it can be solved at users side, I will add this to vuepress-plugin-md-enhance, if some lines must be changed at @vuepress/markdown I will open a PR to add this as a built-in function. Ok to you? @meteorlxy

@meteorlxy
Copy link
Member

Nope, I think that's hard. I was trying to build one long time ago, but I met some issues.

Well, it seems to work well here with a rough test 🤔 .

@Mister-Hope
Copy link
Member

Mister-Hope commented Jun 15, 2022

Use vuepress-plugin-md-enhance@next, and enable attrs.

@vuepress vuepress locked and limited conversation to collaborators Jun 15, 2022
@vuepress vuepress unlocked this conversation Jun 15, 2022
@Mister-Hope Mister-Hope closed this as not planned Won't fix, can't repro, duplicate, stale Jun 15, 2022
@meteorlxy
Copy link
Member

Don't close issue too casually. We could consider to integrate it .

@Mister-Hope
Copy link
Member

Emm, I don't think this is a core feature though. We EVEN do not add full support for gfm, so what makes you reconsider this one?🧐

@Mister-Hope
Copy link
Member

Mister-Hope commented Jun 15, 2022

Also, the original markdown-it-attrs should be modified to only suppor heading ids, or it may breaks peoples markdown content.

After I support attrs yesterday, I already received a report saying that his content is parsed incorrectly today hours ago, and some content are parsed as attrs.

Anyway if you do think that we need heading ids, I can open a pr to support that.

@Mister-Hope
Copy link
Member

Meanwhile, I would also consider features like link-checking or gfm are more important than this one. If you still want to enlarge core markdown features, I would suggest adding these as well.

@meteorlxy
Copy link
Member

what makes you reconsider this one?

As we are providing i18n support out-of-the-box, it's helpful when switching languages and keep the current hash.

@Mister-Hope
Copy link
Member

link-checking or gfm

Any suggestions about the above one? Some users complain that they can't keep markdown file as is from github markdown to our tool.

Also the image link discussed in the other issue is also a big problem.

@xianghongai
Copy link
Author

## 插入图片示例 <!-- #insert-image -->

## Insert Image <!-- #insert-image -->

This way of marking does not break the Markdown syntax.

@Mister-Hope
Copy link
Member

Mister-Hope commented Jun 15, 2022

Nice idea, it also does not break tools like prettier or markdownlint.

Actually we can just keep that syntax, becase we can use \{ to prevent markdown attrs plugin to parse.

The problem is that it adds support in many places, see https://vuepress-theme-hope.github.io/v2/md-enhance/guide/attrs.html#demo.

If we include it as is, the chance breaking user content might be a little high, as it's possible for user content to include {xxx}

@Mister-Hope
Copy link
Member

Mister-Hope commented Aug 17, 2022

Update here, md-enhance already support attrs. See https://vuepress-theme-hope.github.io/v2/md-enhance/guide/attrs.html#demo to use this.

So if this needs to be added in core just copy my code.

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

No branches or pull requests

3 participants