I am using bookdown
to create a "book", in both PDF and HTML.
In places where I have a video for the HTML, I get this message when I render:
Error: Functions that produce HTML output found in document targeting latex output. Please change the output type of this document to HTML. Alternatively, you can allow HTML output in non-HTML formats by adding this option to the YAML front-matter of your rmarkdown file:
always_allow_html: true
Note however that the HTML output will not be visible in non-HTML formats.
Following these instructions about always_allow_html
seems to be discouraged by yihui (https://github.com/rstudio/bookdown/issues/440):
You should not add always_allow_html: yes to YAML.
So, a search yields a solution (e.g. https://bookdown.org/yihui/bookdown/html-widgets.html):
Since knitr v1.13, HTML widgets will be rendered automatically as screenshots taken via the webshot package (Chang 2019). Of course, you need to install the webshot package. Additionally, you have to install PhantomJS (http://phantomjs.org), since it is what webshot uses to capture screenshots. Both webshot and PhantomJS can be installed automatically from R:
...and some instructions given, which I have followed.
So now, I have webshot
and phantomjs
download and installed by following those instructions, which is easily confirmed:
> webshot::is_phantomjs_installed()
[1] TRUE
> webshot:install_phantomjs()
It seems that the version of `phantomjs` installed is greater than or equal to the requested version.To install the requested version or downgrade to another version, use `force = TRUE`.
Error in webshot:install_phantomjs() : argument of length 0
Whether I use webshot:install_phantomjs()
or webshot:install_phantomjs(force=TRUE)
, nothing changes.
Indeed, this fails:
> webshot:install_phantomjs(version="2.1.1", force=TRUE)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 637 100 637 0 0 0 1585 0 --:--:-- --:--:-- --:---:-- --:--:-- 1588
0 16.3M 100 16.3M 100 16.3M 0 0 3244k 0 0:00:05 0:00:05 --:--:-- 3926k
0:01 0:10:39 49930phantomjs has been installed to /Users/pdunn2/Library/Application Support/PhantomJS
Error in webshot:install_phantomjs(version = "2.1.1", force = TRUE) :
argument of length 0
So... if webshot
and phantomjs
appear to be installed... what am I doing wrong?
Thanks for direction...
P.
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] webshot_0.5.2 bookdown_0.20
loaded via a namespace (and not attached):
[1] packrat_0.5.0 digest_0.6.25 jsonlite_1.7.0 magrittr_1.5 evaluate_0.14 rlang_0.4.7 stringi_1.4.6
[8] curl_4.3 rstudioapi_0.11 rmarkdown_2.3 webshot_0.5.2 tools_4.0.2 stringr_1.4.0 xfun_0.15
[15] yaml_2.2.1 rsconnect_0.8.16 compiler_4.0.2 askpass_1.1 htmltools_0.5.0 openssl_1.4.2 knitr_1.29