core
core copied to clipboard
Explicit ids?
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
- https://www.npmjs.com/package/markdown-it-attrs
- https://github.com/valeriangalliat/markdown-it-anchor#explicit-ids
Alternative
No response
Additional context
No response
## 插入图片示例 {#insert-image}
## Insert Image {#insert-image}
I do think about supporting it, currectly our logic is to apply a default slugify function on title.
@meteorlxy Any suggestion with this one?
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.
I've noticed this before in some docs translation repo. I think users could use it with
extendsMarkdownby themselves as needed.
Nope, I think that's hard. I was trying to build one long time ago, but I met some issues.
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
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 🤔 .
Use vuepress-plugin-md-enhance@next, and enable attrs.
Don't close issue too casually. We could consider to integrate it .
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?🧐
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.
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.
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.
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.
## 插入图片示例 <!-- #insert-image -->
## Insert Image <!-- #insert-image -->
This way of marking does not break the Markdown syntax.
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}
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.