inline table styling with Blastula

Blastula appears to not respect the <style> tags used by table formatting packages like kableextra and formattable. (Prior unsolved issues here and here).

Example:

library(kableExtra)
library(blastula)

dt <- mtcars[1:5, 1:6]

tbl <- dt %>%
  kbl() %>%
  kable_styling()

tbl

compose_email(
  body = md(c(
    "this is my table:",
    tbl
    )))

Displays this when printing tbl

But this when printing the compose_email version:

I think the solution is to use inline formatting.

Is there a way to add inline table styling to tables to get:

  • 2 px grey border under the header row
  • 1 px light grey border between the table rows
  • Minimum row height or padding to space the table a little more

Bonus points for changing the font and adding column padding!

I had this problem and I believe the solution is inline formatting as you say. You can use the kableExtra functions column_spec and row_spec e.g. (related to my own code)

... %>%
  kableExtra::column_spec(column = 1:4, extra_css = 'border-bottom: 1px solid black; padding: 4px;') %>% 
  kableExtra::row_spec(row = 1, extra_css = 'border-top: 1px solid black; padding: 4px;')