Rapporter / pander

An R Pandoc Writer: Convert arbitrary R objects into markdown
http://rapporter.github.io/pander/
Open Software License 3.0
294 stars 66 forks source link

Column width issue when plain.ascii = TRUE #321

Closed dcomtois closed 5 years ago

dcomtois commented 6 years ago

Hi Gergely,

I noticed that when plain.ascii = TRUE, the column width, in this particular situation, is not adapted to printed content:

obj <- structure(list(Variable = "age  \n[numeric]", 
                      `Text Graph` = ". \\ \\ \\ \\ . \\ \\ \\ \\ \\ \\ \\ \\ . \\ \\ . :\n: . . : : : \\ \\ : : . : :\n: : : : : : : : : : : :\n: : : : : : : : : : : :\n: : : : : : : : : : : :\n: : : : : : : : : : : :", 
                      Valid = "975  \n(97.5%)", Missing = "25  \n(2.5%)"), 
                 .Names = c("Variable", "Text Graph", "Valid", "Missing"), 
                 row.names = 1L, class = "data.frame")

pander(obj, style = "multiline", plain.ascii = TRUE, justify = "left", 
       keep.line.breaks = TRUE, split.tables = Inf, split.cells = Inf)

# -----------------------------------------------------------------------
# Variable    Text Graph                              Valid     Missing  
# ----------- --------------------------------------- --------- ---------
# age         .     .         .   . :                 975       25       
# [numeric]   : . . : : :   : : . : :                 (97.5%)   (2.5%)   
#             : : : : : : : : : : : :                                    
#             : : : : : : : : : : : :                                    
#             : : : : : : : : : : : :                                    
#             : : : : : : : : : : : :                                    
# -----------------------------------------------------------------------

# The width is the same as it would using 'plain.ascii = FALSE'
pander(obj, style = "multiline", plain.ascii = FALSE, justify = "left", 
       keep.line.breaks = TRUE, split.tables = Inf, split.cells = Inf)

# -----------------------------------------------------------------------
# Variable    Text Graph                              Valid     Missing  
# ----------- --------------------------------------- --------- ---------
# age         . \ \ \ \ . \ \ \ \ \ \ \ \ . \ \ . :   975       25       
# [numeric]   : . . : : : \ \ : : . : :               (97.5%)   (2.5%)   
#             : : : : : : : : : : : :                                    
#             : : : : : : : : : : : :                                    
#             : : : : : : : : : : : :                                    
#             : : : : : : : : : : : :                                    
# -----------------------------------------------------------------------

Not sure if that's an easy fix or not though...?

Thx