Skip to content

Commit 03e907a

Browse files
committed
fall back to html_document for default_output_format() if output format can't be recognized in YAML (this is mainly used in RStudio IDE)
1 parent 841200a commit 03e907a

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: rmarkdown
33
Title: Dynamic Documents for R
4-
Version: 2.30.2
4+
Version: 2.30.3
55
Authors@R: c(
66
person("JJ", "Allaire", , "jj@posit.co", role = "aut"),
77
person("Yihui", "Xie", , "xie@yihui.name", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-0645-5666")),

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ rmarkdown 2.31
55

66
- Use the argument `--syntax-highlighting` for Pandoc >= 3.8 since `--highlight-style` has been deprecated (thanks, @ywwry66, #2602).
77

8+
- `default_output_format()` will fall back to `html_document` if the output format in YAML cannot be recognized.
9+
810

911
rmarkdown 2.30
1012
================================================================================

R/output_format.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,12 @@ default_output_format <- function(input, output_yaml = NULL) {
436436

437437
# look up the formals of the output function to get the full option list and
438438
# merge against the explicitly set list
439-
format_function <- eval(xfun::parse_only(format$name))
439+
format_function <- tryCatch(
440+
eval(xfun::parse_only(format$name)), error = function(e) NULL
441+
)
442+
# if we can't find the function, default to html_document with no options
443+
if (!is.function(format_function))
444+
return(list(name = "html_document", options = list()))
440445
format$options <- merge_lists(as.list(formals(format_function)),
441446
format$options,
442447
recursive = FALSE)

0 commit comments

Comments
 (0)