Skip to content

Commit f3ec6e2

Browse files
authored
fix: do not autolink code that is in a link (#2972)
* fix: do not autolink code that is in a link * test: add test for code within href * news item
1 parent c07d935 commit f3ec6e2

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# pkgdown (development version)
22

3+
* do not autolink code that is in a link (href) in Rd files (#2972)
4+
35
# pkgdown 2.2.0
46

57
* Make `build_llm_docs()` more robust to the use of old Pandoc (@nanxstats, @galachad, #2952, #2954)

R/rd-html.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ as_html.tag_url <- function(x, ...) {
160160
}
161161
#' @export
162162
as_html.tag_href <- function(x, ...) {
163-
a(flatten_text(x[[2]]), href = flatten_text(x[[1]]))
163+
# don't link since we are in a link
164+
a(flatten_text(x[[2]], auto_link = FALSE), href = flatten_text(x[[1]]))
164165
}
165166
#' @export
166167
as_html.tag_email <- function(x, ...) {

tests/testthat/test-rd-html.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,13 @@ test_that("bad specs throw errors", {
319319
})
320320
})
321321

322+
test_that("no autolink in href", {
323+
expect_equal(
324+
rd2html("\\href{https://example.com}{\\code{download.file()}}"),
325+
"<a href='https://example.com'><code>download.file()</code></a>"
326+
)
327+
})
328+
322329
# Paragraphs --------------------------------------------------------------
323330

324331
test_that("empty input gives empty output", {

0 commit comments

Comments
 (0)