R/parse_links.R

Defines functions parse_links

Documented in parse_links

#' Get all links contained in a wikitext string
#'  
#' Vectorized over rev.
#'
#' @param rev A character vector, like one built with \code{page_content} function
#'
#' @return If \code{length(rev) = 1}, a character vector containing all links. If \code{length(rev) > 1}, a list of character vector.
#' @export
#'
#' @importFrom stringr str_extract_all
#'
parse_links <- function(rev) {
  
  lapply(rev, function(x) {
    str_extract_all(x, "\\[\\[(?:[^|\\]]*\\|)?([^\\]]+)\\]\\]")[[1]]
  })
  
}
cafeine05/WikiSocio documentation built on Nov. 17, 2018, 10:01 a.m.