gt icon indicating copy to clipboard operation
gt copied to clipboard

Bulleted lists only making 1 bullet

Open rjake opened this issue 3 years ago • 3 comments

I'm really liking gt. I might be doing something wrong here but I thought this code would result in a bulleted list

library(tidyverse)
library(glue)
library(gt)

mpg %>% 
  distinct(manufacturer, class, model) %>% 
  head(10) %>% 
  group_by(manufacturer) %>% 
  summarise(
    about = 
      glue("* **{model}**: _{class}_") %>% # <--- where I'm trying to make bullets
      glue_collapse("<br>")
  ) %>% 
  ungroup() %>% 
  gt() %>% 
  cols_align("left") %>% 
  fmt_markdown(columns = everything())

image

rjake avatar Aug 02 '21 21:08 rjake

We will look into this because this definitely does not look right.

rich-iannone avatar Nov 04 '21 16:11 rich-iannone

A closer to minimal reprex:

library(gt)
data.frame(column = "* blt1<br>* blt2") |>
  gt() |>
  fmt_markdown(columns = everything())
column
  • blt1
    * blt2

Created on 2024-01-25 with reprex v2.0.2

The issue seems to be with the commonmark dependency:

commonmark::markdown_html("* blt1<br>* blt2")
#> [1] "<ul>\n<li>blt1<br>* blt2</li>\n</ul>\n"

Created on 2024-01-25 with reprex v2.0.2

The output should be like this, I believe.

 <ul>
    <li>blt1</li>
    <li>blt2</li>
 </ul>

kendonB avatar Jan 25 '24 20:01 kendonB

And using the newline character works as OP expected:

library(gt)
data.frame(column = "* blt1\n* blt2") |>
  gt() |>
  fmt_markdown(columns = everything())
column
  • blt1
  • blt2

Created on 2024-01-26 with reprex v2.0.2

kendonB avatar Jan 25 '24 20:01 kendonB