R/fixAnchorLinks.R

Defines functions fixAnchorLinks

Documented in fixAnchorLinks

#' @title fixAnchorLinks
#' @description Converts `(blah)[#tag]` notation to react component: `<AnchorLink href="#tag">blah</AnchorLink>`
#' @param md a markdown string or vector
#' @family markdown
#' @seealso [parseGPmarkdown()]
#' @export
#
fixAnchorLinks<-function(md){
  pat<- "\\[([^\\[]*?)\\]\\((#.*?)\\)"

  stringr::str_replace_all(string=md,pattern=pat,"<AnchorLink href=\"\\2\"> \\1 </AnchorLink>")
}
galacticpolymath/GPpub documentation built on April 5, 2025, 6:04 p.m.