parse_single_annotation: Parse an hierarchical annotation into a data.frame

View source: R/parse_annotation.R

parse_single_annotationR Documentation

Parse an hierarchical annotation into a data.frame

Description

This function converts a markdown-style hierarchical annotation into a data.frame with from -> to columns. For example a text like this:#' #Heading 1 #Heading 2 ##Heading 2.1 ##Heading 2.2 #Heading 3 would be converted to a data.frame with all the links (e.g. Heading 2 -> Heading 2.1)

Usage

parse_single_annotation(note, pattern = "#+")

Arguments

note

a length 1 character vector, with an annotation to be parsed

pattern

a length 1 character vector, with the pattern to parse the annotation. This is passed to stringr::str_split and stringr::str_extract_all. The default value matches 1 or more hashtags (#) and succesive hashtags indicate the level of the title/code

Value

a data.frame

Examples

parse_single_annotation(
  "#1 ##1.1 ##1.2 ###1.2.1 ###1.2.2 ##1.3 #2 ##2.1 ###2.1.1"
)

edalfon/efun documentation built on June 23, 2024, 4:17 a.m.