Skip to content

Invalid reference in [[toc]] with plugin markdown-it-custom-header-link #1979

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

Closed
1 task done
abernov opened this issue Oct 25, 2019 · 6 comments
Closed
1 task done

Comments

@abernov
Copy link

abernov commented Oct 25, 2019

  • I confirm that this is an issue rather than a question.

Bug report

if header has custom link (used plugin markdown-it-custom-header-link) then the table of content has a wrong link.

Steps to reproduce

install markdown-it-custom-header-link
add plugin to config

set header link
## title <!-- link -->

add [[toc]]

What is expected?

What is actually happening?

in [[toc]]wrong reference to this header

Other relevant information

How to resolve:

for reference in the vuepress [[toc]] need use token.attr.id or $page.headers.slug

Then all will work fine!

  • Output of npx vuepress info in my VuePress project:
@kefranabg
Copy link
Collaborator

VuePress is using markdown-it-table-of-contents which is not able to understand markdown-it-custom-header-link syntax.

Why do you need your link to be different from your header title?

@brindosch
Copy link

Hello @kefranabg,
Sadly, i noticed the same with the "badge" feature.

### TEXT <Badge text="TBA 2.1+"/>

The [[TOC]] will create a link to #text-badge-text-tba-2-1: instead of #text

@kefranabg
Copy link
Collaborator

kefranabg commented Oct 25, 2019

@brindosch your comment is not related to the initial issue. Please create a new issue, if you think you've found a bug.

@abernov
Copy link
Author

abernov commented Oct 25, 2019

Why do you need your link to be different from your header title?

  1. I need references from my WEB-app to vuepress docs headers.
    App is Multilingual. In this case, each language has its own unique link to header.

  2. Easier to create a new locale. Copy the existing one - all inner links will remain. You only need to translate the text.

see also discuss at this Feature request

@abernov
Copy link
Author

abernov commented Oct 25, 2019

I look at code of markdown-it-table-of-contents plugin.

This plugin needs to be rewritten for badge and custom link works.

No bug in this plugin! It just needs to be rewritten!

@kefranabg
Copy link
Collaborator

Unfortunately we don't own this plugin, you can still try to open an issue to the toc repos, but i don't think maintainers will accept such a feature 🤔

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

No branches or pull requests

3 participants