Skip to contents

Given a character vector and the regular expression for the shorthand bookmark value specifications, return an object with the extracted identifiers, keys, values, and the line numbers where they were found.

Usage

get_shorthand_values(
  x,
  bm_shorthand_regex = bookmark::opts$get("bm_shorthand_regex")
)

Arguments

x

The character vector.

bm_shorthand_regex

The shorthand bookmark value specifications regular expression.

Value

A list of lists, where each list contains $lineNrs, $match, $id, $key, and $value.

Examples

bookmark::get_shorthand_values(
  c("First line",
    "<!--[BOOKMARK::author::name::Gjalt-Jorn Peters]-->",
    "Second line",
    "Third line")
);
#> $rawRes
#> $rawRes[[1]]
#> $rawRes[[1]]$lineNrs
#> [1] 2
#> 
#> $rawRes[[1]]$match
#> [1] "<!--[BOOKMARK::author::name::Gjalt-Jorn Peters]-->"
#> 
#> $rawRes[[1]]$id
#> [1] "author"
#> 
#> $rawRes[[1]]$key
#> [1] "name"
#> 
#> $rawRes[[1]]$values
#> [1] "Gjalt-Jorn Peters"
#> 
#> 
#> 
#> $sortedRes
#> $sortedRes$author
#> $sortedRes$author$name
#> [1] "Gjalt-Jorn Peters"
#> 
#> 
#>