Skip to content

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

Closed

Description

@cderv

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

Activity

  1. added
    bug
    on Feb 9, 2021
  2. github-actions commented on Aug 10, 2021

    @github-actions

    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.

  3. locked as resolved and limited conversation to collaborators on Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions