hughjonesd / huxtable

An R package to create styled tables in multiple output formats, with a friendly, modern interface.
http://hughjonesd.github.io/huxtable
Other
322 stars 28 forks source link

Markdown output can fail when splitting multiple lines #178

Closed hughjonesd closed 4 years ago

hughjonesd commented 4 years ago
library(dplyr)
library(huxtable)
hux(
        c("some longish text gets wrapped and messed up", "some more text"), 
        c("***A long cell that will be wrapped***", "more text")
      ) %>% 
      set_markdown(1:2, 2, TRUE)

The problem (I think) is that strwrap in character_matrix is not colour-aware.

hughjonesd commented 4 years ago

One solution: use strwrap_ctl() from the fansi package within character_matrix. They claim it is much faster than the base equivalent! fansi is C-based, so you can't just copy-paste the function; the package is about 265 kB; but it's already imported by tibble and cli so probably fairly common.