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

Escape html in comments in author info from DESCRIPTION #1204

Merged
merged 7 commits into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# pkgdown (development version)

* pkgdown now escapes html and linkifies links in comments in author info from DESCRIPTION (@maelle, #1204)

* add support for navbar submenus: you can create submenus following the convention established in [rstudio/rmarkdown#721](https://github.com/rstudio/rmarkdown/issues/721) (@ijlyttle, @wendtke, #1213)

* pkgdown now uses the ORCiD logo included in Font Awesome 5.11 instead of
Expand Down
2 changes: 1 addition & 1 deletion R/build-home-authors.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ author_desc <- function(x, comment = TRUE) {
if (!is.null(x$orcid))
x$orcid,
if (comment && !is.null(x$comment) && length(x$comment) != 0)
paste0("<br/>\n<small>(", x$comment, ")</small>")
paste0("<br/>\n<small>(", linkify(x$comment), ")</small>")
)
}

Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-build-home-authors.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ test_that("names can be removed from persons", {
expect_length(remove_name(p4$comment, "ORCID"), 0)
expect_length(remove_name(p5$comment, "ORCID"), 0)
})

test_that("Comments in authors info are linkified", {
p <- list(name = "Jane Doe", roles = "rev", comment = "<https://x.org/>")

expect_match(
author_desc(p),
"&lt;<a href='https://x.org/'>https://x.org/</a>&gt;)</small>"
)
})