Skip to content
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)

* do not autolink code that is in a link (href) in Rd files (#2972)

# pkgdown 2.2.0

* Make `build_llm_docs()` more robust to the use of old Pandoc (@nanxstats, @galachad, #2952, #2954)
Expand Down
3 changes: 2 additions & 1 deletion R/rd-html.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ as_html.tag_url <- function(x, ...) {
}
#' @export
as_html.tag_href <- function(x, ...) {
a(flatten_text(x[[2]]), href = flatten_text(x[[1]]))
# don't link since we are in a link
a(flatten_text(x[[2]], auto_link = FALSE), href = flatten_text(x[[1]]))
}
#' @export
as_html.tag_email <- function(x, ...) {
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-rd-html.R
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,13 @@ test_that("bad specs throw errors", {
})
})

test_that("no autolink in href", {
expect_equal(
rd2html("\\href{https://example.com}{\\code{download.file()}}"),
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked that this fails on main 😸

"<a href='https://example.com'><code>download.file()</code></a>"
)
})

# Paragraphs --------------------------------------------------------------

test_that("empty input gives empty output", {
Expand Down