Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to deal with DOIs that include ">" #1164

Closed
maelle opened this issue Nov 3, 2020 · 2 comments · Fixed by #1315
Closed

How to deal with DOIs that include ">" #1164

maelle opened this issue Nov 3, 2020 · 2 comments · Fixed by #1315
Labels
bug an unexpected problem or unintended behavior rd ✍️

Comments

@maelle
Copy link
Contributor

maelle commented Nov 3, 2020

From https://stat.ethz.ch/pipermail/r-package-devel/2020q4/006236.html

If one has a DOI like <doi:10.1175/1520-0469(1981)038<1179:TSLROA>2.0.CO;2> in the package DESCRIPTION one needs to URLencode it for R CMD check to pass. I.e. "doi:10.1175/1520-0469(1981)038%3C1179:TSLROA%3E2.0.CO;2"

The problem is that the URL encoded version of the URL then gets written in the package-level manual page. And when going from Rd to HTML, the DOI is truncated after the "%".

Could roxygen2 transform DOIs to URLs and unencode their text?

@maelle
Copy link
Contributor Author

maelle commented Nov 3, 2020

Like what pkgdown does in some places actually https://github.com/r-lib/pkgdown/blob/810084e8a9abd091378a6b75fa9d7de9ce637aa1/R/html-build.R#L16 🤔 (the linkifying, but not the unescaping of the DOI, which is ok I suppose).

What one gets as index page with pkgdown in the absence of an index source is nice with the clickable DOIs.

@hadley hadley added bug an unexpected problem or unintended behavior rd ✍️ labels Apr 16, 2021
@dieghernan
Copy link
Contributor

Hi! I am exploring a PR for solving #1265 and I just came across this issue. Just for information, I found the following on https://github.com/wch/r-source/:

https://github.com/wch/r-source/blob/51cfc84111f51048bf9415f17a8910650492c6a2/src/library/tools/R/doitools.R#L32-L40

    dois <- character()
    pattern <- "<(DOI|doi):([^>]*)>"
    if(!is.na(v <- meta["Description"])) {
        m <- gregexpr(pattern, v)
        dois <- c(dois, .gregexec_at_pos(pattern, v, m, 3L))
    }
    ## DOI names may contain ">", but we need this as a delimiter when
    ## writing the names in <doi:name> style.  So at least ">" and hence
    ## also "%" must be percent encoded ...
    doi_db(utils::URLdecode(dois), rep.int("DESCRIPTION", length(dois)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior rd ✍️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants