rstudio / gt

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

Using `gt::md()` renders different markdown syntax differently, depending upon where it is called. #1892

Open rich-iannone opened 1 month ago

rich-iannone commented 1 month ago

Using gt::md() renders different markdown syntax differently, depending upon where it is called.

Reprex:

---
format:
   docx: default
---

```{r}
gt::gt(gt::sp500[1:10, ]) |>
  gt::tab_header(gt::md("**Test header** <br>*__Test header two__*")) |>
  gt::tab_footnote(gt::md("_Test footnote_ <br>*__Test footnote two__*"))

Note:

Screenshot 2024-09-26 at 16 17 06

Versions:

Originally posted by @MikeJohnPage in https://github.com/rstudio/gt/issues/1067#issuecomment-2377118729

rjazwiec commented 1 month ago

Will add here because my issue is very similar.

code:

 tab_spanner(., label = md("t~max~ [h]"), columns = matches("tmax")) %>% 
  tab_spanner(., label = md("C~max~ [ng/mL]"), columns = matches("cmax")) %>%
  tab_spanner(., label = md("t~1/2~ [h]"), columns = matches("t1_2")) %>%
  tab_spanner(., label = md("AUC~0-24h~ [h×ng/mL]"), columns = matches("auc_0_24h"))

generates output like this:

tab_sp_20mg_cr1

when there are only numbers and letters in the subscript part everything renders properly:

tab_sp_20mg_cr2

Any other sign between ~ makes it render strikethrough instead of subscript (vulgar ½ doesn't work either)

tab_sp_20mg_cr3

It works like this in pdf, png, html. In docx output it doesn't render subscript in tab_spanner at all just puts C~max~ as it is with tildas visible

Best regards Radek

ps. I just saw that GH has done the same with Cmax above. max is typed between ~ (one per side not two) and is rendered as striketrough.

rjazwiec commented 1 month ago

Also md("AUC$_{0-24h}$ [h×ng/mL]") renders properly.