Skip to content

Instantly share code, notes, and snippets.

View r-leyshon's full-sized avatar

Richard Leyshon r-leyshon

  • Office for National Statistics Data Science Campus
  • Wales, United Kingdom
View GitHub Profile
@r-leyshon
r-leyshon / render_toc.R
Created August 10, 2021 06:16 — forked from gadenbuie/render_toc.R
Generate Manual Table of Contents in (R)Markdown Documents
#' 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