Closed bastistician closed 1 month ago
AFAICS, these four lines could simply be replaced by
meta$URL = sub('[, \t\n].*', '', meta$URL)
given that the URLs can be separated by comma or whitespace.
That sounds okay to me, but I'll let @dmurdoch confirm it since the two sub()
s were from the PR #2264.
I don't remember why I had the R < 4.3.2 dependency, but if it was necessary, at least it will go away over time.
Okay, then I guess we can try to use the single sub()
as @bastistician suggested.
The intention of #2264 was "if multiple URLs are present, drop all but the first" and that is also what is documented in
help(write_bib)
:Unfortunately, this is not always true and may depend on the R version. For example:
In R 4.3.0 (as intended):
In R 4.4.0 (2nd URL in note field, 3rd URL ignored):
The problematic code seems to be here: https://github.com/yihui/knitr/blob/726fe1553ace340789e2a649b328c3ecb5ebae4a/R/citation.R#L96-L99 I don't understand where these two replacement steps came from, but the second one is only active if it finds a space (so not for "polyclip", see above). AFAICS, these four lines could simply be replaced by
given that the URLs can be separated by comma or whitespace.