namedropR
namedropR copied to clipboard
Change to webshot2 to support special characters in key
Currently, export_as = "png")
fails when the keys (and thus file-names) contain characters that need to be escaped in HTML. For instance:
library(namedropR)
drop_name_crossref("https://doi.org/10.1037/bul0000315", export_as = "png")
#> No cite_key specified. Working through all possible 1 entries in the bibliography.
#> Could not load file:///private/var/folders/xk/g0cqx1hs53z_txqsyq74jzcc0000gn/T/RtmpxTyQg9/reprex-9e542a3778c7-hexed-tuna/visual_citations/G%EF%BF%BDtz_2020.html
#> Could not take a screenshot of the intermediate HTML.
#> <simpleError in webshot::webshot(output_file, paste0(output_file, ".png"), selector = ".visual-citation", zoom = 2): webshot.js returned failure value: 1>
#> [1] "visual_citations/Götz_2020.html.png"
This is because phantomjs converts URLs and escapes special characters. Since that is not really a bug, I'm not very optimistic that we can get that changed - so I would suggest changing to (webshot2)[] which intends to supersede webshot, is better supported and does not struggle with this case.
library(webshot2)
file1 <- "Götz_2020.html"
writeLines("<html><body>hello world!</body></html>", file1)
webshot(file1)
Created on 2022-12-11 with reprex v2.0.2