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 and cderv committed Jan 30, 2024
1 parent a1dbd20 commit 17ae138
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 @@ -22,6 +22,7 @@ Imports:
rmarkdown,
rstudioapi,
utils,
tools,
yaml
Suggests:
curl,
Expand All @@ -31,7 +32,7 @@ Suggests:
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 @@ -26,5 +26,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 17ae138

Please sign in to comment.