Skip to content

Commit

Permalink
Vignette engines for Quarto (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcnorris authored Nov 3, 2023
1 parent 8173583 commit 9dc50eb
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ Imports:
rsconnect (>= 0.8.26),
rstudioapi,
utils,
tools,
yaml
Suggests:
knitr,
testthat (>= 3.1.0),
withr,
xfun
VignetteBuilder:
knitr
knitr, quarto
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ importFrom(rlang,is_interactive)
importFrom(rmarkdown,relative_to)
importFrom(rstudioapi,isAvailable)
importFrom(rstudioapi,viewer)
importFrom(tools,vignetteEngine)
importFrom(utils,browseURL)
importFrom(yaml,write_yaml)
24 changes: 24 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

#' Register engines to support Quarto vignettes
#' @importFrom tools vignetteEngine
#' @noRd
.onLoad <- function(libname, pkgname) { # args ignored
vignetteEngine(name = "pdf",
package = "quarto",
pattern = "[.]qmd$",
weave = function(file, ..., encoding = "UTF-8") {
quarto_render(file, ..., output_format = "pdf")
},
tangle = vignetteEngine("knitr::rmarkdown")$tangle,
aspell = vignetteEngine("knitr::rmarkdown")$aspell
)
vignetteEngine(name = "html",
package = "quarto",
pattern = "[.]qmd$",
weave = function(file, ..., encoding = "UTF-8") {
quarto_render(file, ..., output_format = "html")
},
tangle = vignetteEngine("knitr::rmarkdown")$tangle,
aspell = vignetteEngine("knitr::rmarkdown")$aspell
)
}
36 changes: 36 additions & 0 deletions vignettes/hello.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: "Quarto Vignettes"
format:
pdf:
toc: false
html:
toc: true
vignette: >
%\VignetteIndexEntry{Vignettes}
%\VignetteEngine{quarto::pdf}
%\VignetteEncoding{UTF-8}
---

## Hello Vignette World!

This is an example Quarto vignette, demonstrating how the **quarto** package can let you write package vignettes in Quarto.

## Two Vignette Engines

The **quarto** package registers 2 vignette engines, `quarto::pdf` and `quarto::html`. Either of these may be selected in a Quarto vignette's YAML header. For example, this vignette's header reads:
```yaml
---
title: "Quarto Vignettes"
format:
pdf:
toc: false
html:
toc: true
vignette: >
%\VignetteIndexEntry{Vignettes}
%\VignetteEngine{quarto::pdf}
%\VignetteEncoding{UTF-8}
---
```

Consequently, a PDF version of this vignette is built.

0 comments on commit 9dc50eb

Please sign in to comment.