Skip to content

Commit

Permalink
fix yihui#2343: remove anything after comma or white spaces (includin…
Browse files Browse the repository at this point in the history
…g \n) in package URL
  • Loading branch information
yihui committed May 26, 2024
1 parent f1788b8 commit d499d2a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: knitr
Type: Package
Title: A General-Purpose Package for Dynamic Report Generation in R
Version: 1.46.4
Version: 1.46.5
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("Abhraneel", "Sarma", role = "ctb"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- `write_bib()` now escapes all non-escaped "&" in the bibliography by default. Previously, it only escaped the title field of the package citation. You can disable the escape with the argument `tweak = FALSE` (thanks, @HedvigS #2335, @atusy #2342).

## BUG FIXES

- Fixed a bug that `write_bib()` fails to use the first URL of a package when multiple URLs are provided in DESCRIPTION and separated by `\n` (thanks, @bastistician, #2343).

## MINOR CHANGES

- The syntax highlighting LaTeX commands for Rnw documents, `\hlstr` and `\hlstd`, were renamed to `\hlsng` and `\hldef`, respectively, to maintain consistency with Andrew Simon's highlight package (thanks, @dcser123, #2341).
Expand Down
9 changes: 2 additions & 7 deletions R/citation.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,8 @@ write_bib = function(
# don't use the citation() URL if the package has provided its own URL
cite = citation(pkg, auto = if (is.null(meta$URL)) meta else {
if (packageURL) meta$Repository = meta$RemoteType = NULL
# the package may have provided multiple URLs, in which case we use the
# first. We also work around a bug in citation() up to R 4.3.1. The grep
# pattern here is problematic, but it's what citation() was using.
if (getRversion() < '4.3.2' && grepl('[, ]', meta$URL))
meta$URL = sub('[, ].*', '', meta$URL)
# always remove URLs after the first one
meta$URL = sub(',? .*', '', meta$URL)
# use the first URL in case the package provided multiple URLs
meta$URL = sub('[, \t\n].*', '', meta$URL)
meta
})
if (tweak) {
Expand Down

0 comments on commit d499d2a

Please sign in to comment.