Skip to content

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

Open
zmughal wants to merge 1 commit intowilkelab:masterfrom
zmughal-contrib:unicode-linebreak-glue
Open

fix: Do not split on Unicode characters with Line_Break=Glue property#38
zmughal wants to merge 1 commit intowilkelab:masterfrom
zmughal-contrib:unicode-linebreak-glue

Conversation

@zmughal
Copy link
Copy Markdown

@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
Copy link
Copy Markdown
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