Skip to content

Quarto vignettes: biocstyle-html / biocstyle-pdf formats and engines (#121) - #132

Merged
seandavi merged 16 commits into
develfrom
feature/quarto-parity
Nov 17, 2026
Merged

seandavi merged 16 commits into
develfrom
feature/quarto-parity

Conversation

@seandavi

@seandavi seandavi commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Implements the Quarto feature parity tracked in #121: a biocstyle Quarto extension bundled with BiocStyle (formats biocstyle-html and biocstyle-pdf), vignette engines BiocStyle::quarto_html / BiocStyle::quarto_pdf, use_vignette_quarto() / use_quarto_extension(), an "Authoring Quarto vignettes" vignette, tests, and CI.

Parity map

R Markdown (BiocStyle) Quarto equivalent Status
BiocStyle::html_document theme biocstyle-html: SCSS theme (BiocBlue #1a81c2 headings/links, green #87b13f title, shaded code, table header shading) ✅
BiocStyle::pdf_document (Bioconductor.sty) biocstyle-pdf loads the same Bioconductor.sty via include-in-header ✅
Author / affiliation / email block, abstract Quarto author schema; custom title-block.html (HTML) and title.tex/before-body.tex partials (authblk, PDF). Numbered affiliations, * email marks, no marks when all authors share one affiliation (follows #53) ✅
"Package: X version" (package:) Lua filter; version passed by the engine as package-version, or read from ../DESCRIPTION when previewing ✅
Floating left TOC toc: true, toc-location: left, "Contents" title ✅
fig.small / fig.wide figure classes fig-small / fig-wide (chunk option classes: or {.fig-small} on images/divs); fig-wide maps to Quarto's column-page-right ✅ (see notes)
Horizontally scrolling tables post-render Lua filter wraps tables in div.horizontal-scroll ✅
Sidenotes / margin footnotes reference-location: margin (HTML). PDF: same placement as pdf_document (bottom of page in both) ✅
Biocpkg(), CRANpkg(), Githubpkg() inline R, unchanged ✅ (no shortcode)
%\VignetteEngine{knitr::rmarkdown} %\VignetteEngine{BiocStyle::quarto_html} / quarto_pdf ✅
use_vignette_html() / use_vignette_pdf() use_vignette_quarto(name, format = c("html", "pdf")) ✅
RStudio template inst/quarto/templates/vignette.qmd, used by use_vignette_quarto() (package-vignette structure from #76) ✅ (no RStudio "New File" menu entry; see below)
md_document Quarto gfm n/a
Caption titles (titlecaps, bold blue first sentence) — ❌ not done

Design notes

  • Extension location: inst/quarto/_extensions/biocstyle/ (not bioconductor/biocstyle as sketched in Quarto feature parity with R Markdown vignettes #121), so formats are biocstyle-html / biocstyle-pdf, matching the existing Bioconductor/quarto-extensions draft.
  • PDF approach: reusing Bioconductor.sty worked, so no reduced header was needed. The extension carries a copy (shipped next to the document with format-resources, because \usepackage cannot see the installed package's path); test_quarto_extension_sty_matches_resources fails if the two copies drift, and it already caught pdf_document: subtitle is never shown in the PDF #122's change, which is synced here. Three partials replace Quarto's title.tex, before-body.tex and toc.tex with the authblk author block, abstract, \packageVersion{} and a TOC on its own page. The format sets documentclass: article and pdf-engine: pdflatex (the sty passes pdftex to hyperref), and Quarto's Shaded and verbatim environments use the sty's myshaded.
  • Lua filters: biocstyle-figures.lua runs at pre-ast, before Quarto turns figures into floats. biocstyle.lua handles metadata after Quarto normalizes authors (by-author / by-affiliation). biocstyle-post.lua runs at post-render and handles table wrapping plus the soul-safe inline code that pdf_document's post-processor also produces.
  • Figure sizes: classes don't change the knitr device size, so the docs say to pair fig-small with fig-width: 5 and fig-wide with fig-width: 10 (the format defaults to 8×5). That matches fig.small / fig.wide. Quarto has no user opts_hooks, so this can't be automatic.
  • Engines: they use only the exported quarto API (quarto_path(), quarto_render()). At weave time they copy the installed extension to _extensions/biocstyle next to the input; an existing _extensions/biocstyle is used as is, and other extensions are never touched. They then render, remove only what they created (plus the Bioconductor.sty that format-resources drops), and move the output to the working directory when it differs from the input's directory (tools::buildVignette(dir=)). During the render they set R_LIBS from .libPaths() and unset R_TESTS; without that, rendering from R CMD check tests failed because Quarto's R process could not find startup.Rs. Without Quarto: error interactively; under R CMD check, warn and write a placeholder (as in add BiocStyle quarto engine #115). Tangle and aspell come from knitr's rmarkdown engine.
  • Preview: use_quarto_extension() copies the extension into vignettes/_extensions/ and adds vignettes/_extensions and vignettes/Bioconductor.sty to .Rbuildignore / .gitignore when those files exist. BiocStyle's own .Rbuildignore gets the same two entries, and the repo gets a new .gitignore with them.
  • DESCRIPTION: quarto in Suggests, VignetteBuilder: knitr, BiocStyle, SystemRequirements mentions Quarto (optional). NAMESPACE has two new exports; only man/use_vignette_quarto.Rd is new. roxygen2 8.1.0's reformatting of NAMESPACE/DESCRIPTION was reverted to keep the diff small.
  • CI: check.yml and render-matrix.yml install Quarto with quarto-dev/quarto-actions/setup@v2, after apt-installing sudo jq wget curl, which the action needs inside the Bioconductor container. The render matrix also builds the Quarto vignette and runs test_quarto.R. These steps use Quarto's bundled pandoc, so they don't vary with the matrix. required-packages.txt gains a section with the TeX packages Quarto's template uses; that edit landed in the merge commit that resolved the install-tex.R conflict.

How to try it

BiocStyle::use_vignette_quarto("MyPackage")            # vignettes/MyPackage.qmd + vignettes/_extensions
BiocStyle::use_vignette_quarto("MyPackage-pdf", "pdf")

Then quarto render vignettes/MyPackage.qmd (or the RStudio Render button), or R CMD build with VignetteBuilder: BiocStyle and Suggests: BiocStyle, knitr, quarto. vignette("AuthoringQuartoVignettes", package = "BiocStyle") walks through every feature and has a table mapping R Markdown features to Quarto.

Verification (local, macOS arm64, R 4.6.0, Quarto 1.9.38, quarto R 1.5.1)

  • R CMD build then _R_CHECK_FORCE_SUGGESTS_=false R CMD check --no-manual (after merging devel at 5fd68a9): Status: OK, no NOTEs/WARNINGs/ERRORs. 57 RUnit test functions with 0 errors and 0 failures, including 10 in test_quarto.R.
  • CI on the first push (devel at 7a1ba01): all jobs green. In R CMD check (Bioc devel), the Quarto vignette built and the run ended with 1 NOTE (pdf_document.Rd: includes missing a package anchor), which devel's own run also reports. In every pandoc-matrix job, test_quarto.R ran 10 functions with 0 errors, 0 failures and none deactivated. The advisory BiocCheck step adds one new warning: BiocStyle is listed in VignetteBuilder but not in its own Suggests. The quarto package handles the same self-reference the same way, so I left it.
  • test_quarto.R with Quarto hidden from PATH: 4 rendering tests DEACTIVATED, the rest pass. buildVignette() errors interactively and warns plus writes a placeholder when _R_CHECK_PACKAGE_NAME_ is set.
  • Side-by-side screenshots (Rmd vs Quarto, same content) were checked by eye.
  • Not verified: Windows and Linux locally (Linux only through CI); RStudio's Render button; Quarto versions other than 1.9.38 (quarto-required: ">=1.4.0" is a guess, since at: filter entry points and format-resources need ≥1.4).

Not done

  • Caption titles (titlecaps: bold blue first sentence of figure/table captions) in HTML.
  • No Quarto shortcode for Biocpkg() & co.; inline R works.
  • No RStudio "File → New File" template entry. RStudio has no package-provided Quarto templates, so use_vignette_quarto() is the entry point.
  • Sizes and spacing are not pixel-identical. Quarto figures render larger and without crop, and the HTML body isn't indented under hanging section numbers as html_document's is.
  • Bioconductor/quarto-extensions is not updated to mirror this extension.

Open questions for maintainers

  1. Is fig-small / fig-wide with a recommended fig-width the idiom you want, or should we document Quarto's column: options only?
  2. Is a copy of Bioconductor.sty in the extension, guarded by a test, acceptable, or would you prefer the engine copy it in at render time? The trade-off: the extension would no longer be self-contained for previews and for mirroring.
  3. Should quarto-extensions mirror this extension?

Supersedes #115. Many thanks to Marcel Ramos (@LiNk-NY) for the engine in #115, which this adapts, and to @federicomarini for the palette and testing in #114/#115.

seandavi and others added 16 commits November 17, 2026 09:25
Quarto extension bundled at inst/quarto/_extensions/biocstyle that gives
Quarto documents the features of BiocStyle::html_document and
BiocStyle::pdf_document (#121):

- biocstyle-html: SCSS theme with the Bioconductor palette (BiocBlue
  #1a81c2 headings and links, green #87b13f title; palette from
  bioconductor.css and #114), floating left TOC, numbered sections,
  footnotes in the margin, title block with authors, affiliations,
  emails, date, abstract and package line.
- biocstyle-pdf: loads the same Bioconductor.sty as pdf_document via
  include-in-header (copied next to the document with format-resources),
  with title/before-body/toc partials for the authblk author block,
  abstract and \packageVersion line.
- biocstyle.lua: 'package:' field -> 'Package X version' (version from
  the 'package-version' metadata set by the vignette engines, falling
  back to ../DESCRIPTION when previewing), fig-small / fig-wide figure
  classes, authblk commands for PDF.
- biocstyle-post.lua: wrap HTML tables in a horizontal-scroll container;
  drop control spaces in inline code for Bioconductor.sty's soul.

Bioconductor.sty is a copy of inst/resources/tex/Bioconductor.sty so the
extension is self-contained; a unit test keeps the two identical.

Co-Authored-By: Claude <noreply@anthropic.com>
Register two vignette engines for .qmd files in .onLoad. At weave time
they copy the installed biocstyle Quarto extension to _extensions/biocstyle
next to the vignette (a user's existing _extensions/biocstyle is used as
is, and other extensions in _extensions are left alone), render with
quarto::quarto_render(output_format = 'biocstyle-html' / 'biocstyle-pdf')
passing the version of the package named in 'package:' as
'package-version' metadata, then remove only what they created. Only the
exported quarto API is used; quarto goes in Suggests.

Without the quarto package or the Quarto CLI the engines error, except
under R CMD check, where they warn and write a placeholder. Tangling and
spell-checking reuse knitr's rmarkdown engine.

DESCRIPTION: quarto in Suggests, BiocStyle added to VignetteBuilder (for
BiocStyle's own Quarto vignette), SystemRequirements mentions Quarto.

Engine adapted from #115 by Marcel Ramos (@LiNk-NY).

Co-Authored-By: Claude <noreply@anthropic.com>
use_vignette_quarto(name, format = c('html', 'pdf')) creates
vignettes/<name>.qmd from inst/quarto/templates/vignette.qmd, with the
%\VignetteIndexEntry and %\VignetteEngine{BiocStyle::quarto_<format>}
header and the package-vignette structure from #76 (installation, quick
start, support site, bug reports, session info). It then calls
use_quarto_extension().

use_quarto_extension(dir = 'vignettes') copies the extension to
<dir>/_extensions/biocstyle so 'quarto render' and the RStudio Render
button work when previewing, and adds <dir>/_extensions and the
Bioconductor.sty that PDF previews leave behind to .Rbuildignore and
.gitignore when those files exist. An existing _extensions/biocstyle is
only replaced with overwrite = TRUE; other extensions are never touched.

Also ignore BiocStyle's own preview leftovers in vignettes/.

Co-Authored-By: Claude <noreply@anthropic.com>
inst/unitTests/test_quarto.R renders inst/unitTests/cases/quarto_parity.qmd
with both engines and checks one structural marker per row of the parity
map in #121: title, subtitle, authors/affiliations/email, abstract,
package line with version, left TOC, numbered sections, margin footnote,
fig-small/fig-wide classes, scroll-wrapped table, Biocpkg()/CRANpkg()
links, and the SCSS palette in the embedded CSS. The PDF test checks
that it compiles and, with pdftotext, the title block text.

Also tests use_vignette_quarto() and use_quarto_extension() in a temporary
package, that neither the engine nor use_quarto_extension() deletes an
existing _extensions, the ../DESCRIPTION version fallback used when
previewing, and that the extension's Bioconductor.sty matches
inst/resources/tex/Bioconductor.sty.

Rendering tests are DEACTIVATED when the quarto package or CLI is missing.

Co-Authored-By: Claude <noreply@anthropic.com>
- Move the fig-small / fig-wide handling to biocstyle-figures.lua, run at
  pre-ast so fig-wide also maps to column-page-right on figure divs and
  Markdown images before Quarto turns them into floats. Metadata handling
  stays in biocstyle.lua at the default stage, after Quarto has
  normalized authors.
- PDF header: define Shaded when the document has no highlighted code.

Co-Authored-By: Claude <noreply@anthropic.com>
A Quarto vignette built with BiocStyle::quarto_html that documents and
demonstrates the biocstyle formats: setup (DESCRIPTION fields, header,
use_vignette_quarto(), previewing with use_quarto_extension()), a table
mapping R Markdown features to their Quarto equivalents, the title block,
style macros, regular/small/wide figures, scrolling tables, margin
footnotes, and PDF output.

Co-Authored-By: Claude <noreply@anthropic.com>
URLdecode() grows its output byte by byte and took over a minute on the
embedded Bootstrap stylesheet; decode with a vectorized helper instead.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
- check.yml: install the Quarto CLI with quarto-dev/quarto-actions/setup@v2
  (plus sudo/jq/wget, which the action needs in the container) before
  R CMD check, so the Quarto vignette and test_quarto.R run.
- render-matrix.yml: same setup; build AuthoringQuartoVignettes.qmd with
  the BiocStyle::quarto_html engine and run test_quarto.R.
- install-tex.R: add LaTeX packages Quarto's template uses.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
- R CMD check sets R_TESTS to a startup file relative to tests/, which the
  R process Quarto starts cannot find, so rendering from unit tests (or
  any package's tests) failed. Unset it for the duration of the render.
- Update the extension's copy of Bioconductor.sty to devel's (#122
  subtitle support); test_quarto_extension_sty_matches_resources caught
  the drift. With it, the Quarto PDF subtitle is typeset by
  Bioconductor.sty's \maketitle as in pdf_document.

Co-Authored-By: Claude <noreply@anthropic.com>
Follow devel's #53 change to parse_auth_affil()/auth_affil_latex(): when
every author has the same single affiliation, the title block shows the
affiliation without superscript numbers (HTML), and the PDF emits an
unmarked authblk \affil in block layout. Tested in
test_quarto_preview_reads_description.

Co-Authored-By: Claude <noreply@anthropic.com>
@seandavi
seandavi merged commit 710ab4f into devel Nov 17, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant