Gt: footnote/markdown combo not working (in bookdown)

Created on 8 Jan 2019  路  2Comments  路  Source: rstudio/gt

When trying to add a footnote containing markdown, the formatting is not maintained when using bookdown.
Consider:

---
title: Bug Report
subtitle: No `markdown` formatting in footnote
date: '`r format(Sys.time(), "%d %B, %Y")`'
author: r-cheologist
output:
  bookdown::pdf_document2
---

```{r prerequisites, message = FALSE}
library(magrittr)
requireNamespace('gt')
```

```{r table, results='asis'}
data.frame(
  A      = 1:5,
  B      = rep('Longer than longish group label', times = 5),
  groups = c(
    rep('Longish group label', times = 2),
    rep('Label', times = 3))) %>%
  gt::gt(groupname_col = 'groups') %>%
  gt::tab_footnote(
    footnote = gt::md("**This** ought to be bold, *that* italic & ^yonder^ superscript."),
    locations = gt::cells_column_labels(gt::vars(A))
  )
```

which (independently of whether results = 'asis' is set or not) produces
this

[2] Intermediate [2] Medium [3] High 鈽癸笌 Bug

Most helpful comment

I dug into this a little more, and my issue is not the same as the OP.

"^" is not interpreted as superscript by commonmark::markdown_html markdown converter called by {gt}. HTML tags are passed through, so the solution is to use until commonmark supports "^". This is confusing since rmarkdown::render() uses pandoc to convert markdown to HTML, which does interpret "^" as superscript.

Also worth noting that OP's footnote does get bold and italics when rendering to HTML, but not when rendering to PDF.

All 2 comments

I just ran into something similar using gt::md() to format a title.

This:

tab_header(title = md("未^13^C of *NOSAMS* and **external** standards"))

italicizes and bolds correctly, but the superscript is interpreted literally.

I dug into this a little more, and my issue is not the same as the OP.

"^" is not interpreted as superscript by commonmark::markdown_html markdown converter called by {gt}. HTML tags are passed through, so the solution is to use until commonmark supports "^". This is confusing since rmarkdown::render() uses pandoc to convert markdown to HTML, which does interpret "^" as superscript.

Also worth noting that OP's footnote does get bold and italics when rendering to HTML, but not when rendering to PDF.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

courtiol picture courtiol  路  3Comments

scotbader8858 picture scotbader8858  路  4Comments

jestarr picture jestarr  路  3Comments

DickStartz picture DickStartz  路  4Comments

vikram-rawat picture vikram-rawat  路  3Comments