create_toc_entries: Create table of contents entries from web page content

View source: R/create_toc_entries.R

create_toc_entriesR Documentation

Create table of contents entries from web page content

Description

Given a html file, parse throught the file looking for h3 html nodes. Each node is formatted using format_toc_entry() and returned as a character vector.

Usage

create_toc_entries(
  html_file,
  node_type = "h1, h3",
  padding_map = c(h1 = "0em", h3 = "2em"),
  include_page_name = TRUE
)

Arguments

html_file

a html file

node_type

character string defaults to "h3"

padding_map

a named character vector used to map node types to padding strings for the table of contents entry

include_page_name

a logical if true, the table of contents begins with a link to the page as the first entry.

Details

The function create_toc_entries expects a flexdashboard with H3 headers (### in rmarkdown). In addtion, the header should be followed by a tag identical to the heading but without white space e.g., #HeaderasisWithoutSpaces. The function is used for the side-effect of directly printing table of contents entries.

Use node_type = "h3" to find rmarkdown ### headers or node_type = "h1" to find rmarkdown page headers. node_type = "h2" refers to column or row oobjects in a flexdashboard.

Examples

create_toc_entries(system.file("extdata", "curios-test-flexdashboard.html",
package = "curios"))

create_toc_entries(system.file("extdata",
"curios-test-flexdashboard.html", package = "curios"), node_type = "h3")

johnaclouse/curios documentation built on June 14, 2022, 6:45 a.m.