HenrikBengtsson / R.rsp

:page_facing_up: R package: Dynamic generation of scientific reports
https://henrikbengtsson.github.io/R.rsp/
31 stars 6 forks source link

Add encoding for Static HTML Vignettes #42

Closed TomKellyGenetics closed 9 months ago

TomKellyGenetics commented 3 years ago

Thanks for developing a great package. This is very useful for examples take more than 10 minutes or use files over 5 MB which exceeds CAN limits.

The example asis files in R_packages-Static_PDF_and_HTML_vignettes.pdf cause issues with some characters in the vignette. Specifying the encoding fixes this.

%\VignetteIndexEntry{R packages: Static PDF and HTML vignettes}
%\VignetteEngine{R.rsp::asis}
+%\VignetteEncoding{UTF-8}
%\VignetteKeyword{PDF}
-%\VignetteKeyword{HTML}
-%\VignetteKeyword{vignette}
-%\VignetteKeyword{package}

I think it should also be may clear that keywords are not strictly necessary but anything in your Rmarkdown yaml header should be included in asis too.

vignette: >
  %\VignetteIndexEntry{Simulating network graph structure in continuous data}
  %\VignetteEngine{R.rsp::asis}
  %\VignetteEncoding{UTF-8}
HenrikBengtsson commented 3 years ago

The example asis files in R_packages-Static_PDF_and_HTML_vignettes.pdf cause issues with some characters in the vignette. Specifying the encoding fixes this.

For me to understand and "reproduce" this, can you clarify what "cause issues" means? Are you saying there's something wrong with that particular vignette, i.e. https://cran.r-project.org/web/packages/R.rsp/vignettes/R_packages-Static_PDF_and_HTML_vignettes.pdf?

TomKellyGenetics commented 3 years ago

I recommend updating the example as I had problems following it. I think UTF-8 will work in most cases or advanced users will know to change it.

My vignette has a β character in it which may be causing the problem on my end.

HenrikBengtsson commented 9 months ago

My vignette has a β character in it which may be causing the problem on my end.

I finally had time to try to reproduce this. It took me a while to understand that "it" means the *.asis file and not the static PDF or HTML file. For example, if I add a UTF-8 symbol to the %\VignetteIndexEntry{...} index in the *.asis file, then R CMD build will complain about it:

$ R CMD build R.rsp
* checking for file ‘R.rsp/DESCRIPTION’ ... OK
* preparing ‘R.rsp’:
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
* creating vignettes ... ERROR
Error: Vignette 'R_packages-Static_PDF_and_HTML_vignettes.pdf.asis' is non-ASCII but has no declared encoding
...

Adding %\VignetteEncoding{UTF-8} pleases R CMD build.

I've updated the *.asis example to:

%\VignetteIndexEntry{R packages: Static PDF and HTML vignettes}
%\VignetteEngine{R.rsp::asis}

%% The following is only needed if the *.asis file has
%% a UTF-8 symbol (e.g. in %\VignetteIndexEntry{}):
%\VignetteEncoding{UTF-8}

%% Optional:
%\VignetteKeyword{PDF}
%\VignetteKeyword{HTML}
%\VignetteKeyword{vignette}
%\VignetteKeyword{package}

Hopefully, this helps other people running into UTF-8 related issues in the as-is file.

Thanks again.