diff --git a/NEWS.md b/NEWS.md index f31211751..20ddc1dcd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,6 +13,10 @@ * Multiple `@format` tags are now combined (#1015). +* roxygen2 now omits empty annotations (alternate text) for figures added + via markdown. This caused issues when generating pkgdown web sites + (#1051). + # roxygen2 7.0.2 * `\example{}` escaping has been improved (again!) so that special escapes diff --git a/R/markdown.R b/R/markdown.R index 2dce119f3..37e66867a 100644 --- a/R/markdown.R +++ b/R/markdown.R @@ -348,7 +348,10 @@ mdxml_link_text <- function(xml_contents, state) { mdxml_image = function(xml) { dest <- xml_attr(xml, "destination") title <- xml_attr(xml, "title") - paste0("\\figure{", dest, "}{", title, "}") + paste0( + "\\figure{", dest, "}", + if (nchar(title)) paste0("{", title, "}") + ) } escape_comment <- function(x) { diff --git a/man/markdown_pass1.Rd b/man/markdown_pass1.Rd index 8ddddd48c..087658e48 100644 --- a/man/markdown_pass1.Rd +++ b/man/markdown_pass1.Rd @@ -44,6 +44,6 @@ nrow(mtcars) Plots:\if{html}{\out{
}}\preformatted{plot(1:10) }\if{html}{\out{
}} -\figure{test-figure-1.png}{} +\figure{test-figure-1.png} } \keyword{internal}