Skip to contents

Given a character vector and the regular expression for the bookmark file identifier, return the extracted file identifier itself.

Usage

get_bookmark_id(
  x,
  filename,
  bm_id_regex = bookmark::opts$get("bm_id_regex"),
  bm_id_rmd_regex = bookmark::opts$get("bm_id_rmd_regex")
)

Arguments

x

The character vector.

filename

The file from which the character vector came - used as identifier (sanitized from invalid characters) id no identifier was specified.

bm_id_regex

The bookmark identifier regular expression.

Value

A character vector with the file identifier(s).

Examples

bookmark::get_bookmark_id(
  c("First line",
    "<!--[BOOKMARK::ID::testfile_1]-->",
    "Second line",
    "Third line"),
  filename = "filename.txt"
);
#> [1] "filename"