Skip to content

Avoid em dash conversion in fmt_markdown #1613

Answered by olivroy
wvictor14 asked this question in Q&A
Discussion options

You must be logged in to vote

You'd have to do a manual transformation of your input before.

# this does what you want.
dplyr::tibble(x = '\\-\\-\\-') |> gt() |>  fmt_markdown() 

Programatically, you can do

dplyr::tibble(x = '---') |> dplyr::mutate(x = gsub("-", "\\\\-", x))|>  gt() |>  fmt_markdown() 
# or with stringr
dplyr::tibble(x = '---') |> dplyr::mutate(x = stringr::str_replace_all(x, "-", "\\\\-"))|>  gt() |>  fmt_markdown() 

The problem is that --- is em-dash in markdown, so you need to make sure it looks like \- to avoid markdown interpretation.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rich-iannone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants