-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vignette engines for Quarto #57
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a82e3d1
Register engines quarto::(pdf|html|al)
dcnorris ea311f0
Drop superfluous tools:: qualification
dcnorris 89f1218
Remove the "all" vignette engine for simplicity
dcnorris 4ca88dc
Add example Quarto vignette
dcnorris 6587e41
Three --> Two
dcnorris 80142ee
Merge updated upstream 'origin/main' into vengines
dcnorris 2af337c
Merge branch 'quarto-dev:main' into vengines
dcnorris 3c537bd
Merge branch 'vignette-engine' into vengines
cderv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
}, | ||
dcnorris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tangle = vignetteEngine("knitr::rmarkdown")$tangle, | ||
aspell = vignetteEngine("knitr::rmarkdown")$aspell | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding PDF vignette, we would like to put that on hold for now.
Quarto 1.4 has typst support, with
typst
CLI bundled in Quarto (https://quarto.org/docs/prerelease/1.4/typst.html) and this is a good way to produce PDF faster and more reliable than using LaTeX.This could be safer on CRAN that to rely on the LaTeX installation. Do you have experience on CRAN to build LaTeX vignette ?
If we provice a pdf engine using LaTeX, we should probably tweak the default configuration so that for example latexmk auto install does no happen when running a vignette on CRAN. (I don't know if that is really allowed, and how LaTeX dependencies are handled on CRAN servers to build vignette).
So for now, I would only provide HTML vignette
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not with Quarto, but certainly with Rmd. This vignette for my DTAT package serves to demonstrate the reproducibility of calculations for a peer-reviewed paper, e.g.:
https://cran.r-project.org/web/packages/DTAT/vignettes/dtat.pdf
I would tend to discourage gratuitous FUD here about building LaTeX stuff on CRAN. I don't recall myself ever having to 'downgrade' a PDF vignette to HTML for any technical reason.
See also https://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Writing-package-vignettes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry if my tone was not the good one. (sometimes non native english speaker catch me ... 😞)
I didn't mean to sound like I was doubtful about it working well. It was mainly question about what can really be done considering how quarto is working by default with quarto pdf engine
format: pdf
require LaTeX and some packages. Pandoc's template and some quarto feature have requirement about LaTeX packages. By default, quarto will try to install missing LaTeX packages when rendering errors are found, and then retrigger a render. By "LaTeX installation", I mean which LaTeX extension are available or not. I don't think it is seen as good practice to automatically update tlmgr and install new missing LaTeX package. So I meant it was safer to opt-out this feature, or use PDF output produced byformat: typst
which is quicker to render.I don't know the list of available LaTeX component from CTAN available on CRAN build machine to compare with Pandoc's and Quarto requirement. Maybe this is full texlive install available and so no problem ever.
However, as pointed out in the manual you rightly referenced, including the output in the source would make sure to LaTeX extension installation are needed. So that is a way to make sure it would work.
My concerns is preventing any problem with package building on CRAN because of how quarto works, and what impact building vignette with quarto could have. Maybe this is nothing to worry about.
Anyhow, I hope this clarifies my initial thoughts.