Skip to content

Instantly share code, notes, and snippets.

View thua101's full-sized avatar
Pushing Limit

Tianze Hua thua101

Pushing Limit
View GitHub Profile
@thua101
thua101 / render_toc.R
Created September 27, 2022 19:31 — forked from gadenbuie/render_toc.R
Generate Manual Table of Contents in (R)Markdown Documents
View render_toc.R
#' Render Table of Contents
#'
#' A simple function to extract headers from an RMarkdown or Markdown document
#' and build a table of contents. Returns a markdown list with links to the
#' headers using
#' [pandoc header identifiers](http://pandoc.org/MANUAL.html#header-identifiers).
#'
#' WARNING: This function only works with hash-tag headers.
#'
#' Because this function returns only the markdown list, the header for the