wilkelab / ggtext

Improved text rendering support for ggplot2
https://wilkelab.org/ggtext/
GNU General Public License v2.0
650 stars 37 forks source link

why ggtext::element_markdown() trimmed my multiple whitespace #97

Closed Yiguan closed 1 year ago

Yiguan commented 1 year ago

Hi,

It looks like a weird issue when there are multiple whitespaces in the labels.

Here is the testing code:

# test data, zz is used as axis text
tt <- data.table(xx = 1:5, yy=1:5,zz=c('aa  aaa','ddfd fb','fff                         fb','dddd','fffd'))

ggplot(data=tt) + geom_point(aes(x=xx,y=yy)) +
    scale_y_continuous(breaks=1:5, labels = tt$zz) + 
    theme(axis.text.y = ggtext::element_markdown())

I have some multiple whitespaces in labels. But ggtext::element_markdown() seems only keep one whitespace.

image

> sessionInfo()
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

ggtext_0.1.2

Thanks in advance!

clauswilke commented 1 year ago

Yes, HTML collapses whitespace. That's how it works.