extract_links: Extract links from text

Description Usage Arguments Examples

View source: R/extract_links.R

Description

Helper function that takes a block of text, extracts all markdown formatted links and returns the text with all links stripped out and replaced by footnote references and an array of the new links to add to 'cv_printer' attributes.

Usage

1

Arguments

text

Text containing markdown formatted links.

cv

Object of class 'cv_printer' that has 'links' attribute containing character vector of links. Used to determin what to start footnote reference number at.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
text_w_links <- "Here is my text with a cool [markdown link](https://my_cool_website.com/a_page) in it. For good measure [here's another link.](http://another_cool_site.com/)"

# Setup empty CV printer
printer <- new_cv_printer(list(), pdf_mode = TRUE)

extract_results <- extract_links(text_w_links, printer)

# Text w/ no links is here
extract_results$text

# Extracted links are here
extract_results$links

# No links stored yet
attr(printer, 'links')

# We can then append these links to our CV so it remembers them for later footnote printing
printer <- printer %>% append_links(extract_results$links)

# Links have been updated
attr(printer, 'links')

nstrayer/cvdown documentation built on Feb. 18, 2020, 12:35 a.m.