Skip to content

Commit

Permalink
Prevent error for empty hyperlinks
Browse files Browse the repository at this point in the history
Fixes #72
  • Loading branch information
jeroen committed May 22, 2023
1 parent 008417f commit 5ca6520
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions R/parse-markdown.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ parse_text_md <- function(path, extensions = TRUE, yaml_fields = c("title" ,"sub
link_nodes <- xml2::xml_find_all(doc, "//link[@destination]")
lapply(link_nodes, function(x){
dest <- xml2::xml_attr(x, 'destination')
node <- xml2::xml_find_first(x, "./text")
xml2::xml_set_text(node, sub(dest, '', xml2::xml_text(node), fixed = TRUE))
if(nchar(dest)){
node <- xml2::xml_find_first(x, "./text")
xml2::xml_set_text(node, sub(dest, '', xml2::xml_text(node), fixed = TRUE))
}
})

# Find text nodes and their location in the markdown source doc
Expand Down

0 comments on commit 5ca6520

Please sign in to comment.