repr icon indicating copy to clipboard operation
repr copied to clipboard

Table misalignment when there is a value with an ampersand

Open valentas-kurauskas opened this issue 8 years ago • 1 comments

(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>

valentas-kurauskas avatar Feb 21 '17 13:02 valentas-kurauskas

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"

flying-sheep avatar Feb 21 '17 14:02 flying-sheep