Skip to content

Commit a9d096b

Browse files
committed
don't apply asis output if some option implicitly required wrapping cell div
like if html-table-processing none has been set
1 parent e4844e8 commit a9d096b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/resources/rmd/patch.R

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ wrap_asis_output <- function(options, x) {
103103
if (identical(options[["html-table-processing"]], "none")) {
104104
attrs <- paste(attrs, "html-table-processing=none")
105105
}
106-
106+
107107
# if this is an html table then wrap it further in ```{=html}
108108
# (necessary b/c we no longer do this by overriding kable_html,
109109
# which is in turn necessary to allow kableExtra to parse
@@ -112,9 +112,17 @@ wrap_asis_output <- function(options, x) {
112112
!grepl('^<div class="kable-table">', x)) {
113113
x <- paste0("`````{=html}\n", x, "\n`````")
114114
}
115-
116-
# If asis output, don't include the output div
117-
if (identical(options[["results"]], "asis")) return(x)
115+
116+
# If asis output, don't include the output div,
117+
# unless a feature requiring it is used
118+
# if there additional classes, some added attr,
119+
# then the user is deemed to have implicitly overridden results = "asis"
120+
# (as those features don't work w/o an enclosing div)
121+
needCell <- length(classes) > 1 || isTRUE(nzchar(attrs)) # nolint: object_name_linter, line_length_linter.
122+
123+
if (identical(options[["results"]], "asis") && !needCell) {
124+
return(x)
125+
}
118126

119127
output_div(x, output_label_placeholder(options), classes, attrs)
120128
}

0 commit comments

Comments
 (0)