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

Incorrect table cell width with Unicode soft-hyphen character #368

Open
billdenney opened this issue Dec 9, 2023 · 0 comments
Open

Incorrect table cell width with Unicode soft-hyphen character #368

billdenney opened this issue Dec 9, 2023 · 0 comments

Comments

@billdenney
Copy link

This may be related to #18, #280, or #296

When I add several Unicode soft-hyphen characters (\u00ad), pandoc.table.return() misaligns the text in the cells after the soft-hyphen. My specific example has the issue in the row names.

library(pander)

d <-
  data.frame(
    a = LETTERS[1:2],
    b = paste(letters, collapse = "")
  )
# insert soft hyphen
rownames(d) <- c("a", "w\u00adx\u00ady\u00adz")

# Second row of table does not align
cat(
  pandoc.table.return(d)
)
#> 
#> ----------------------------------------------
#>    &nbsp;      a               b              
#> ------------- --- ----------------------------
#>     **a**      A   abcdefghijklmnopqrstuvwxyz 
#> 
#>  **w­x­y­z**   B   abcdefghijklmnopqrstuvwxyz 
#> ----------------------------------------------

Created on 2023-12-09 with reprex v2.0.2

The soft-hyphen character is detected as having a width of 1 with nchar(), but it appears to result in a width of zero later in the process. My guess is that difference is the source of the issue.

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