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

github_document() should set +gfm_auto_identifiers to the input for TOC to work correctly #2039

Closed
cderv opened this issue Feb 9, 2021 · 1 comment · Fixed by #2040
Closed
Labels
bug

Comments

@cderv
Copy link
Collaborator

@cderv cderv commented Feb 9, 2021

This is from an investigation following a question on Community
https://community.rstudio.com/t/github-document-table-of-contents-links-not-working-for-sections-that-begin-with-numbers/95539/3

At first I thought it was an issue with Pandoc not supporting the correct algorithm even for GFM, but in fact I misunderstood how the auto identifier feature works.

From this anwser on Pandoc dicussion, it seems that the auto identifier creation happens at read time, not write time. This seems counter intuitive but I put theses files togther in this gist: https://gist.github.com/cderv/589912cb000347cf6d22e91adfa852bc

As you see, not providing markdown+gfm_auto_identifiers will not produce the correct identifiers to work in the TOC for Pandoc autolink feature.

This means this works

---
title: "Test"
output:
  github_document:
    md_extension: +gfm_auto_identifiers
    toc: true
---

# 1 Section

Sentence.

and this will produce a non working TOC

---
title: "Test"
output:
  github_document:
    toc: true
---

# 1 Section

Sentence.

I think we should set the extension in rmarkdown if toc = TRUE

@github-actions
Copy link

@github-actions github-actions bot commented Aug 10, 2021

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant