ramnathv / htmlwidgets

HTML Widgets for R
http://htmlwidgets.org
Other
792 stars 205 forks source link

¶ character appearing in html in output of saveWidget #448

Closed anoronh4 closed 1 year ago

anoronh4 commented 1 year ago

i am using the function htmlwidgets::saveWidget(plot, paste0(opt$sampleName,".circos.html"), selfcontained = T, libdir = "lib") and finding an odd artifact, basically the ¶ character appearing 4 times in the top left corner. i see this in two different browsers (chrome and firefox). i have attached the file in this post. A workaround at the moment is to do a replacement on the file using: sed "s/¶/<p><\/p>/g" but i'm wondering if this is maybe a bug or if there's something i can do within R. I am using htmlwidgets_1.5.4 and R version 4.2.2. circos.zip

cpsievert commented 1 year ago

Please provide a fully reproducible code example (i.e., code to reproduce plot) as well as your version of pandoc

anoronh4 commented 1 year ago

Sure! Here's a standalone script with some test data in it: generate_biocircos.txt The output of pandoc -v is:

pandoc 2.19.2
Compiled with pandoc-types 1.22.2.1, texmath 0.12.5.2, skylighting 0.13,
citeproc 0.8.0.1, ipynb 0.2, hslua 2.2.1
Scripting engine: Lua 5.4
User data directory: /home/noronhaa/.local/share/pandoc
Copyright (C) 2006-2022 John MacFarlane. Web:  https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.

just now i noticed that there's a warning: [WARNING] Deprecated: --self-contained. use --embed-resources --standalone when i run the test script, not sure if that's related.

you can try running the script using docker://cmopipeline/biocircos:0.0.1 if that's easier to get the same environment as me.

kellyasche commented 1 year ago

I wanted to comment here as well and confirm that I've been having the same issue as well. I've exported DT() tables, and charts using ggiraph and all have those paragraph marks in the top left corner. They do not appear when selfcontained == FALSE.

Here's a reproducible using DT().

library(tidyverse)
library(htmlwidgets)
library(DT)

Name <- c("A", "B")

Value <- c(5438, 3192, 3215, 1660)

df <- data.frame(Name, Value)

table <- datatable(df)

saveWidget(table, file="table.html", selfcontained = TRUE)

pandoc_version() [1] ‘2.19.2’

cpsievert commented 1 year ago

It appears this is something that should be fixed in pandoc https://github.com/jgm/pandoc/issues/8475. If there isn't a quick response and fix to that issue, we may provide our own fix. In the meantime, you'll have to downgrade to pandoc 2.18

kellyasche commented 1 year ago

Thanks Carson. I looked through the thread/issue you started on the pandoc page and it looks like they closed the issue. What is the resolution? I've been just editing the exported .html code and deleting all the pilcrows.

cpsievert commented 1 year ago

We'll provide a fix in htmlwidgets

kellyasche commented 1 year ago

Okay thanks!