@@ -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