Skip to content

Commit

Permalink
Same TOC docs error - now fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludvig committed Feb 27, 2024
1 parent 679fa38 commit ae320b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
16 changes: 4 additions & 12 deletions R/table_of_content_markdown.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,9 @@
#' set to `NULL` for it to be included.
#'
#' @section Usage:
#' Just drop in a chunk where you want the toc to appear (set `echo=FALSE`):
#' Just drop in a \strong{chunk} where you want the toc to appear (set `echo=FALSE`):
#'
#' # Table of Contents
#'
#' # # Uncomment and use the following
#'
#' # ```{r echo=FALSE}
#'
#' # render_toc("/path/to/the/file.Rmd")
#'
#' # ```
#' render_toc("/path/to/the/file.Rmd")
#' @keywords internal
#' @param filename Name of RMarkdown or Markdown document
#' @param toc_header_name The table of contents header name. If specified, any
Expand All @@ -35,11 +27,11 @@
#' prior to the first header at the base_level are dropped silently.
#' @param toc_depth Maximum depth for TOC, relative to base_level. Default is
#' `toc_depth = 3`, which results in a TOC of at most 3 levels.
render_toc <- function(
filename,
render_toc <- function(filename,
toc_header_name = "Table of Contents",
base_level = NULL,
toc_depth = 3) {

x <- readLines(filename, warn = FALSE)
x <- gsub("<a.*<img.*a>", "", x) # My addition, remove links with images in
x <- paste(x, collapse = "\n")
Expand Down
12 changes: 2 additions & 10 deletions man/render_toc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ae320b7

Please sign in to comment.