gt
gt copied to clipboard
consequence of breaking change in htmltools `0.5.3`
I see from the release of 0.5.3 and issue https://github.com/rstudio/htmltools/issues/305 that there was no expected use-case, so just want to flag this.
Inline printing gt::gt()
tables (though not knitr::kable()
tables) leaves the ``{=html} tag in the printed output.
# no problem
```{r}
x <-gt::gt(head(mtcars))
x
```
# prefix/afix
`r x`
How the tagged output looks -
Use case example
My frequent use case in reports is rendering tables/graphs or text or nothing, depending on available data and/or other specific conditions.
```{r}
knitr::opts_chunk$set(
echo = FALSE,
message = FALSE,
warning = FALSE
)
output_fun <- function(x){
if(x <.5){
"some text"
} else if(x < .8){
x
} # implied else NULL
}
a <- output_fun(.3)
b <- output_fun(.6)
c <- output_fun(.9)
```
```{r}
a
b
c
```
`r a`
`r b`
`r c`
I don't know if this is a "normal" use-case, or whether this matches the expected behaviour on your end, or whether there is a satisfactory work-around. Seeing that there didn't seem to be an expected use-case made me think it would be reasonable to bring it to your attention.
For the time-being, I'm just going to roll-back to 0.5.2.
Many thanks for continuing to provide such excellent tools!
It appears as though this problem is specific to {gt}
. @rich-iannone, would you mind investigating why {gt}
doesn't render properly via inline code chunks (even though things like knitr::kable()
and DT::datatable()
do)
@rich-iannone I think the issue is that maybe inline
argument in the knit_print
method needs to be passed explicitly so that it gets correctly picked up by the htmltools method
See about inline
in https://cran.r-project.org/web/packages/knitr/vignettes/knit_print.html
About the current state with mentioned tools:
-
knitr::kable
does not rely onhtmltools
knit_print
method -
DT::datatable()
uses directly thehtmltools
method -
gt
has its own method before relying onhtmltools
one
Maybe we should move the issue to gt ?
Agree this is something that can be fixed in gt. I moved this issue to https://github.com/rstudio/gt/issues/1055 in rstudio/gt
.
many thanks, all!