Skip to content

[R-pkg-devel] Disable a particular knitr vignette

4 messages · Henrik Bengtsson, Iñaki Ucar

#
Hi everyone,

I have a JSS vignette based on the rticles package. It was compiling
just fine until rticles v0.5 for some reason started requiring pandoc
v2.x for such a document class, and failing otherwise. Due to this
requirement, Windows machines on CRAN show a nasty WARN, because they
still have pandoc v1.x.

It is painful for Uwe to install pandoc v2.x there, so I was wondering
whether there's any easy mechanism to just disable a particular
vignette based on some condition (in this case, it would be "we are on
CRAN, this is Windows and the pandoc version is < 2"; this is easy to
test).

I tried putting a condition for the output format in the YAML header
and it works, i.e.:

output: if (cond) rticles::jss_article else rmarkdown::pdf_document

But rmarkdown::pdf_document fails to compile, because the JSS class
has many custom macros. I tried also putting a NULL or a NA there, and
it doesn't work.

Does any knitr ninja here know if there's some easy trick to do this
and make Uwe's life easier? Some "NULL" document format?

Regards,
I?aki
#
As a workaround, until resolved, you could precompile your vignette
into a PDF and then use the 'R.rsp::asis' vignette engine
(%\VignetteEngine{R.rsp::asis} etc) to include it as a static PDF.
This is described in the vignettes
(https://cran.r-project.org/package=R.rsp).

-Henrik
On Thu, Aug 2, 2018 at 10:04 AM I?aki ?car <i.ucar86 at gmail.com> wrote:
#
El jue., 2 ago. 2018 a las 11:41, Henrik Bengtsson
(<henrik.bengtsson at gmail.com>) escribi?:
Thanks for the suggestion, Henrik. I would prefer, though, not to
change the behaviour on other platforms and not to rely on another
dependency just for a workaround.

I?aki
#
For anyone interested, I finally managed to solve this, following a
suggestion by Baptiste Auguie. TLDR; my yaml header reads as follows:

output: if (packageVersion("rticles") < 0.5 || rmarkdown::pandoc_version() >= 2)
  rticles::jss_article else rmarkdown::html_vignette

This fallback simply ignores the fancy latex commands and produces a
HTML output, which prevents R CMD check from complaining.

Regards,
I?aki
El jue., 2 ago. 2018 a las 10:04, I?aki ?car (<i.ucar86 at gmail.com>) escribi?:
--
I?aki ?car
http://www.enchufa2.es
@Enchufa2