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

fix: Do not split on Unicode characters with Line_Break=Glue property #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zmughal
Copy link

@zmughal zmughal commented Dec 2, 2024

Specifically, this allows for using non-breaking space ("\u00A0", " ")
in text which is preserved when using SVG output.

Connects to:


Further test on SVG:

test_that("SVG preserves non-breaking spaces", {
  g <- textbox_grob(
    "S&nbsp;M&nbsp;E<br>B I A",
    width = unit(100, "pt"))

  # Create a temporary SVG file
  tmp_svg <- tempfile(fileext = ".svg")
  svglite::svglite(tmp_svg, width = 5, height = 5)
  grid.draw(g)
  dev.off()

  # Read SVG content
  svg_content <- readLines(tmp_svg)
  unlink(tmp_svg)  # cleanup

  text_elements <- svg_content[grep("^<text", svg_content)]
  text_inner <- text_elements |> purrr::map( ~ gsub('[^>]*>(.*</text>)$', '\\1', .x ) )

  expect_contains(text_inner,
                  c('S\u00A0M\u00A0E</text>',
                    'B</text>',
                    'I</text>',
                    'A</text>'))
})

Specifically, this allows for using non-breaking space ("\u00A0", "&nbsp;")
in text which is preserved when using SVG output.

Connects to:
- <wilkelab#35>,
- <wilkelab/ggtext#95>.
@zmughal zmughal force-pushed the unicode-linebreak-glue branch from 15b3187 to a09a9da Compare December 2, 2024 06:55
zmughal added a commit to insilica/clinicaltrials-compliance-study that referenced this pull request Dec 2, 2024
Needed to preserve the `&nbsp;` in SVG output.

Connects with <wilkelab/gridtext#38>.
zmughal added a commit to insilica/clinicaltrials-compliance-study that referenced this pull request Dec 2, 2024
Needed to preserve the `&nbsp;` in SVG output.

Connects with <wilkelab/gridtext#38>.
@zmughal
Copy link
Author

zmughal commented Dec 2, 2024

@bwiernik , seems that the action needs to be updated per https://github.com/wilkelab/gridtext/actions/runs/12111467778?

r-lib/actions/setup-r@v1 is deprecated. Please update your workflow to use the 'v2' version. Also look at the examples at https://github.com/r-lib/actions/tree/v2/examples because '@v2' workflows are much simpler than 'v1' workflows.

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

Successfully merging this pull request may close these issues.

1 participant