Skip to content

Commit 17ae138

Browse files
dcnorriscderv
authored andcommitted
Vignette engines for Quarto (#57)
1 parent a1dbd20 commit 17ae138

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

DESCRIPTION

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Imports:
2222
rmarkdown,
2323
rstudioapi,
2424
utils,
25+
tools,
2526
yaml
2627
Suggests:
2728
curl,
@@ -31,7 +32,7 @@ Suggests:
3132
withr,
3233
xfun
3334
VignetteBuilder:
34-
knitr
35+
knitr, quarto
3536
Config/testthat/edition: 3
3637
Encoding: UTF-8
3738
Roxygen: list(markdown = TRUE)

NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ importFrom(rlang,is_interactive)
2626
importFrom(rmarkdown,relative_to)
2727
importFrom(rstudioapi,isAvailable)
2828
importFrom(rstudioapi,viewer)
29+
importFrom(tools,vignetteEngine)
2930
importFrom(utils,browseURL)
3031
importFrom(yaml,write_yaml)

R/zzz.R

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
#' Register engines to support Quarto vignettes
3+
#' @importFrom tools vignetteEngine
4+
#' @noRd
5+
.onLoad <- function(libname, pkgname) { # args ignored
6+
vignetteEngine(name = "pdf",
7+
package = "quarto",
8+
pattern = "[.]qmd$",
9+
weave = function(file, ..., encoding = "UTF-8") {
10+
quarto_render(file, ..., output_format = "pdf")
11+
},
12+
tangle = vignetteEngine("knitr::rmarkdown")$tangle,
13+
aspell = vignetteEngine("knitr::rmarkdown")$aspell
14+
)
15+
vignetteEngine(name = "html",
16+
package = "quarto",
17+
pattern = "[.]qmd$",
18+
weave = function(file, ..., encoding = "UTF-8") {
19+
quarto_render(file, ..., output_format = "html")
20+
},
21+
tangle = vignetteEngine("knitr::rmarkdown")$tangle,
22+
aspell = vignetteEngine("knitr::rmarkdown")$aspell
23+
)
24+
}

vignettes/hello.qmd

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: "Quarto Vignettes"
3+
format:
4+
pdf:
5+
toc: false
6+
html:
7+
toc: true
8+
vignette: >
9+
%\VignetteIndexEntry{Vignettes}
10+
%\VignetteEngine{quarto::pdf}
11+
%\VignetteEncoding{UTF-8}
12+
---
13+
14+
## Hello Vignette World!
15+
16+
This is an example Quarto vignette, demonstrating how the **quarto** package can let you write package vignettes in Quarto.
17+
18+
## Two Vignette Engines
19+
20+
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:
21+
```yaml
22+
---
23+
title: "Quarto Vignettes"
24+
format:
25+
pdf:
26+
toc: false
27+
html:
28+
toc: true
29+
vignette: >
30+
%\VignetteIndexEntry{Vignettes}
31+
%\VignetteEngine{quarto::pdf}
32+
%\VignetteEncoding{UTF-8}
33+
---
34+
```
35+
36+
Consequently, a PDF version of this vignette is built.

0 commit comments

Comments
 (0)