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

TOC links to header with badge fail #1275

Closed
1 task done
nklayman opened this issue Feb 10, 2019 · 5 comments
Closed
1 task done

TOC links to header with badge fail #1275

nklayman opened this issue Feb 10, 2019 · 5 comments
Labels
contribution welcome Contributions welcome has PR Has a related PR

Comments

@nklayman
Copy link

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

Bug report

When a header includes a badge, a TOC will report an incorrect scroll link for that header.

Version

0.14.8

Steps to reproduce

  1. go to https://v0.vuepress.vuejs.org/guide/markdown.html#table-of-contents
  2. click "Import Code Snippets"

What is expected?

It should scroll to the header link

What is actually happening?

nothing happens

Other relevant information

  • Your OS: Ubuntu 18.10
  • Node.js version: 10.15.1
  • Browser version: chrome 72
  • Is this a global or local install? local
  • Which package manager did you use for the install? yarn
@ulivz
Copy link
Member

ulivz commented Feb 11, 2019

This is known issue, see: #645 (comment)

markdown-it-table-of-contents will extract the all the sub tokens as the slug which brings the inconsistency, so it will cause links in TOC to be unable to navigate to the correct location. maybe we need to create a custom TOC component/plugin for it.

We can create a Vue component <TOC /> to replace current [[ TOC ]], you can use $page.headers to access current page's headers.

Contribution welcome!

@ulivz ulivz added the contribution welcome Contributions welcome label Feb 11, 2019
@shigma
Copy link
Collaborator

shigma commented Feb 17, 2019

We can create a Vue component <TOC /> to replace current [[ TOC ]], you can use $page.headers to access current page's headers.

Since TOC plugin is included in @vuepress/markdown, which was depended on by @vuepress/core, do you mean @vuepress/markdown should provide a global component <TOC />?

@ulivz
Copy link
Member

ulivz commented Feb 17, 2019

@shigma What I meant is to write a VuePress plugin that implements a Vue SFC named TOC to help users to create table of contents, it can be used to replace the default toc but works better.

@shigma
Copy link
Collaborator

shigma commented Feb 17, 2019

@ulivz I mean since [[TOC]] is supported by default, we should also support <TOC/> as a global component by default. Introducting a new plugin may result in breaking changes.

@shigma
Copy link
Collaborator

shigma commented Feb 18, 2019

I have tried to implement it and here is the pr: #1307.

@shigma shigma added the has PR Has a related PR label Feb 27, 2019
@ulivz ulivz closed this as completed in 760f90b Mar 2, 2019
ulivz added a commit that referenced this issue May 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome Contributions welcome has PR Has a related PR
Projects
None yet
Development

No branches or pull requests

3 participants