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.

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"))
#> <BR>
#> <span  style="padding-left: 0em; text-indent: -0em;">[curios-test-flexdashboard](/home/runner/work/_temp/Library/curios/extdata/curios-test-flexdashboard.html#curios-test-flexdashboard) <BR>
#> </span><span  style="padding-left: 0em; text-indent: -0em;">[First flexdashbaord page](/home/runner/work/_temp/Library/curios/extdata/curios-test-flexdashboard.html#first-flexdashbaord-page) <BR>
#> </span><span  style="padding-left: 2em; text-indent: -2em;">[1st H3 header](/home/runner/work/_temp/Library/curios/extdata/curios-test-flexdashboard.html#1st-h3-header) <BR>
#> </span><span  style="padding-left: 2em; text-indent: -2em;">[2nd H3 header](/home/runner/work/_temp/Library/curios/extdata/curios-test-flexdashboard.html#2nd-h3-header) <BR>
#> </span><span  style="padding-left: 2em; text-indent: -2em;">[3rd H3 header](/home/runner/work/_temp/Library/curios/extdata/curios-test-flexdashboard.html#3rd-h3-header) <BR>
#> </span><span  style="padding-left: 0em; text-indent: -0em;">[Second flexdashboard page](/home/runner/work/_temp/Library/curios/extdata/curios-test-flexdashboard.html#second-flexdashboard-page) <BR>
#> </span><span  style="padding-left: 2em; text-indent: -2em;">[Final H3 header](/home/runner/work/_temp/Library/curios/extdata/curios-test-flexdashboard.html#final-h3-header) <BR>
#> </span><BR>

create_toc_entries(system.file("extdata",
"curios-test-flexdashboard.html", package = "curios"), node_type = "h3")
#> <BR>
#> <span  style="padding-left: 0em; text-indent: -0em;">[curios-test-flexdashboard](/home/runner/work/_temp/Library/curios/extdata/curios-test-flexdashboard.html#curios-test-flexdashboard) <BR>
#> </span><span  style="padding-left: 2em; text-indent: -2em;">[1st H3 header](/home/runner/work/_temp/Library/curios/extdata/curios-test-flexdashboard.html#1st-h3-header) <BR>
#> </span><span  style="padding-left: 2em; text-indent: -2em;">[2nd H3 header](/home/runner/work/_temp/Library/curios/extdata/curios-test-flexdashboard.html#2nd-h3-header) <BR>
#> </span><span  style="padding-left: 2em; text-indent: -2em;">[3rd H3 header](/home/runner/work/_temp/Library/curios/extdata/curios-test-flexdashboard.html#3rd-h3-header) <BR>
#> </span><span  style="padding-left: 2em; text-indent: -2em;">[Final H3 header](/home/runner/work/_temp/Library/curios/extdata/curios-test-flexdashboard.html#final-h3-header) <BR>
#> </span><BR>