davidgohel / ReporteRs

Note that ReporteRs has been removed from CRAN the 16th of July 2018 and is not maintained anymore. please migrate to officer.
244 stars 44 forks source link

Error in FlexTable cell text when generating html from Rmd if text starts with `<` #138

Closed jrvianna closed 7 years ago

jrvianna commented 8 years ago

When generating a html from a Rmd document, if the text in a cell starts with <, the resulting text would include <span style=“font-size:11pt;font-family:Times New Roman;color:rgba(0, 0, 0, 1);”> before the proper text (Using Rstudio Knit HTML button). This doesn't happen when visualizing the FlexTable object in the Viewer tab, or when saving to a word file with writeDoc.

Reproducible code chunk example:

table <- data.frame(Variable = c("A", "B", "C"), P.value = c("0.05", "<0.01", "a<0.01"))
vanilla.table(table)

Session Info

## R version 3.3.1 (2016-06-21)
## Platform: x86_64-apple-darwin13.4.0 (64-bit)
## Running under: OS X 10.11.5 (El Capitan)
## 
## locale:
## [1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] ReporteRs_0.8.6     ReporteRsjars_0.0.2
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_0.12.6       png_0.1-7         digest_0.6.10    
##  [4] mime_0.5          R.methodsS3_1.7.1 R6_2.1.2         
##  [7] xtable_1.8-2      magrittr_1.5      evaluate_0.9     
## [10] gdtools_0.0.7     stringi_1.1.1     R.oo_1.20.0      
## [13] R.utils_2.3.0     xml2_1.0.0        rmarkdown_1.0    
## [16] tools_3.3.1       stringr_1.0.0     shiny_0.13.2     
## [19] httpuv_1.3.3      rJava_0.9-8       htmltools_0.3.5  
## [22] rvg_0.1.0         knitr_1.14

PS: Thanks very much for the wonderful package!

davidgohel commented 8 years ago

OK,

< (and few other characters) should be translated into HTML codes. Until it's been solved, a workaround could be:

table <- data.frame(Variable = c("A", "B", "C"), P.value = c("0.05", "&lt;0.01", "a&lt;0.01"))
vanilla.table(table)

This will be rendered as expected within an HTML document but not within a Word document...

David