Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple spaces are trimmed: Leading / trailing spaces are removed, mid-text spaces are converted into a single space #35

Open
yonbar opened this issue Feb 1, 2024 · 0 comments

Comments

@yonbar
Copy link

yonbar commented Feb 1, 2024

Multiple spaces are all trimmed: Leading / trailing spaces are removed, mid-text spaces are converted into a single space.
This includes markdown tricks, e.g.   or "\ua0" , with use_markdown either FALSE or TRUE.


library(gridtext)
library(grid)
library(reprex)

# January is led by regular spaces, March is led by non-breaking spaces by using ALT+0160
text <- c("   January", "Feb&nbsp;&nbsp;&nbsp;ruary", "    March", "\u00a0\u00a0\u00a0April", "____May", "Ju     ne", 
          "July                    ")

x <- (1:7)/9 + 1/30
y <- rep(0.8, 7)
g <- richtext_grob(
  text, x, y, halign = 0, hjust = 1,
  rot = 45,
  padding = unit(c(3, 6, 1, 3), "pt"),
  r = unit(4, "pt"),
  align_widths = TRUE,
  box_gp = gpar(col = "black", fill = "cornsilk", use_markdown = FALSE)
)
grid.newpage()
grid.draw(g)

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

@yonbar yonbar changed the title Multiple spaces are all automatically trimmed to a single space Multiple spaces are trimmed: Leading / trailing spaces are removed, mid-text spaces are converted into a single space Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant