repr
repr copied to clipboard
Table misalignment when there is a value with an ampersand
(Originally posted in https://github.com/IRkernel/IRkernel/issues/447.)
With R backend data.frame(letter=c("A", "B&C", "D"), number=c(1000,2,30))
Displays something like this:
| letter | value |
|---|---|
| A | 1000 |
| A&B | 2 |
| C | 30 |
The misaligned cell in html appears as <span style="white-space:pre-wrap"> 2</span>
OK, so the pre-wrap gets introduced by this function
all matrixes/data.frames go through repr_matrix_generic
the first thing done is ellip_limit_arr(x), which introduces those spaces:
> repr:::ellip_limit_arr(data.frame(letter=c("A", "B&C", "D"), number=c(1000,2,30)))
letter number
1 "A " "1000"
2 "B&C" " 2"
3 "D " " 30"