rstudio / gt

Easily generate information-rich, publication-quality tables from R
https://gt.rstudio.com
Other
2.03k stars 209 forks source link

[FR] a way to not escape the row group label #410

Open shrektan opened 4 years ago

shrektan commented 4 years ago

After PR #252, the row group label will be escaped. However, the user (like me) may need some styled or complicated row group label. I was able to do this by using the raw HTML text as the group column value. Now, it displays raw HTML text and the "escaping behavior" seems unavoidable.

I think being able to use raw HTML text as the row group label is a nice-to-have feature. So I'm here to ask for a feature request.

Thanks.

schloerke commented 4 years ago

Notes...

From a distance...


Since this was merged before the dt_* method conversion,

schloerke commented 4 years ago

Small test cases: (assuming html printing)

## Does contain an `AsIs` class in the column
data.frame(
  group = I("<strong>x</strong> &gt; 30"), 
  value = seq(1, 5)
) %>%
  gt(groupname_col = "group")

## Fully defined list column of html content
tibble::tibble(
  group = list(htmltools::HTML("<strong>x</strong> &gt; 30")), 
  value = seq(1, 5)
) %>%
  gt(groupname_col = "group")

Screen Shot 2019-11-22 at 10 00 44 AM


###
# Does not set up column properly... `group` is a `Factor` heading into `gt`.
# This should produce unexpected results!
### 
data.frame(
  group = htmltools::HTML("<strong>x</strong> &gt; 30"), 
  value = seq(1, 5)
) %>%
  gt(groupname_col = "group")