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

Footnote integration with "On This Page" #4402

Closed
4 tasks done
AmitMY opened this issue Dec 4, 2024 · 2 comments
Closed
4 tasks done

Footnote integration with "On This Page" #4402

AmitMY opened this issue Dec 4, 2024 · 2 comments
Labels
bug: pending triage Maybe a bug, waiting for confirmation

Comments

@AmitMY
Copy link

AmitMY commented Dec 4, 2024

Describe the bug

When using markdown-it-footnote, I manage to get footnotes on the page.
However, when the footnote is on a header
image
the "On this page" section shows it in an undesired way
image

Reproduction

https://stackblitz.com/edit/vitepress-footnote-bug

image

Expected behavior

The footnote should be removed from the "On This Page" area

System Info

reproduced on stackblitz.

Additional context

No response

Validations

@AmitMY AmitMY added the bug: pending triage Maybe a bug, waiting for confirmation label Dec 4, 2024
@brc-dd
Copy link
Member

brc-dd commented Dec 4, 2024

You'll need to adjust mdit config to this:

md.use(footnote)
const orig = md.renderer.rules.footnote_ref!
md.renderer.rules.footnote_ref = (...args) => {
  return orig(...args).replace(
    '<sup class="',
    '<sup class="ignore-header '
  )
}

@brc-dd brc-dd closed this as completed Dec 4, 2024
brc-dd added a commit that referenced this issue Dec 4, 2024
closes #4402
@brc-dd
Copy link
Member

brc-dd commented Dec 4, 2024

Since this is an official mdit plugin, I updated the outline code to ignore footnote-ref by default. From next version you won't need that workaround.

You can use the preview version for now too - npm add -D https://pkg.pr.new/vitepress@1832617

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: pending triage Maybe a bug, waiting for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants