Improve and clarify linking functions
k5cents opened this issue · 0 comments
Right now, there is a mishmash of linking arguments. I like the ability to create very simple named links.
gluedown::md_link(CRAN = "https://cran.r-project.org/")
However, this kind of conflict with the original thesis of the package: vectors to markdown. If the user has programatically created two long vectors of text and links, they should be able to coerce them into a new vector of markdown links. This is currently still possible with the .name
argument, but it feels sloppy.
Ideally you would be able to use text = url
with two vectors, but this kind of naming with dots doesn't work how I'd like.
s <- 1:3
name <- state.name[s]
abb <- glue::glue("https://{state.abb[s]}.gov")
gluedown::md_order(gluedown::md_link(name = abb))
Ideally, it would work more like names(link) <- text
.
names(abb) <- name
gluedown::md_order(glue::glue("[{names(abb)}]({unname(abb)})"))
This same confusion also needs to be cleared up for link labels and references. Also, perhaps we need a single function to do both: print labels and print invisible references.
gluedown::md_bullet(gluedown::md_label(state.name[s], s))
# * [Alabama][1]
# * [Alaska][2]
# * [Arizona][3]
gluedown::md_reference(label = s, url = glue::glue("https://{state.abb[s]}.gov"))
# [1]: https://AL.gov
# [2]: https://AK.gov
# [3]: https://AZ.gov