Skip to content

Commit

Permalink
Fix \figure{} output from md when alternate text is empty
Browse files Browse the repository at this point in the history
Then we need to leave out the second \figure{} argument,
according to WRE. This fixes pkgdown on roxygen2.

Closes #1051.
  • Loading branch information
gaborcsardi committed Mar 6, 2020
1 parent 4fb892f commit 43649c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
* roxygen2 now adds hyperlinks to R6 methods in the PDF manual as well,
(#1006).

* 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
Expand Down
5 changes: 4 additions & 1 deletion R/markdown.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion man/markdown_pass1.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 43649c0

Please sign in to comment.