Skip to content

Commit 6faf61d

Browse files
committed
Replace prerelease-link-subdomain with version-aware shortcode (#1939)
* Replace prerelease-link-subdomain with version-aware shortcode The `prerelease-link-subdomain` variable is phase-aware but not version-aware — on the next RC cycle, old blog posts would incorrectly point to prerelease.quarto.org even though those docs already moved to quarto.org. Add a `prerelease-docs-url` shortcode extension that compares a version argument against the `version` key in `_quarto.yml` to decide whether docs live on quarto.org or prerelease.quarto.org. On the prerelease site (prerelease-docs profile), it always returns "prerelease." regardless of version. Follow-up to #1932, relates to #1934. * Update PDF accessibility blog post to use prerelease-docs-url shortcode (cherry picked from commit 63a21f0)
1 parent f84f210 commit 6faf61d

7 files changed

Lines changed: 84 additions & 17 deletions

File tree

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,24 +132,25 @@ The group order determines which phase is active on **quarto.org** (the main sit
132132
|---|---|
133133
| `_quarto-prerelease-docs.yml` | Site-specific configuration for prerelease.quarto.org |
134134

135-
### Subdomain variables
135+
### Subdomain variable and shortcode
136136

137-
Two variables control how links resolve across builds. Both use the same pattern — `https://{{< meta VAR >}}quarto.org/...` — but serve different purposes:
137+
**`prerelease-subdomain`** — site identity variable ("am I the prerelease site?"). Default `''` in `_quarto.yml`, set to `prerelease.` in `_quarto-prerelease-docs.yml`. Use for self-referential links (e.g. RevealJS demo links back to its own site).
138138

139-
| Variable | Purpose | Default | Set by `rc` | Set by `prerelease-docs` |
140-
|---|---|---|---|---|
141-
| `prerelease-subdomain` | **Site identity** — "am I the prerelease site?" | `''` | — | `prerelease.` |
142-
| `prerelease-link-subdomain` | **Content linking** — "where do prerelease docs live right now?" | `''` | `prerelease.` | `prerelease.` |
139+
**`prerelease-docs-url`** — version-aware shortcode for content linking. Use in blog posts that reference docs only available on prerelease:
143140

144-
Use `prerelease-subdomain` for self-referential links (e.g. RevealJS demo links back to its own site). Use `prerelease-link-subdomain` for content on `main` that references docs only available on prerelease during RC phase (e.g. blog posts announcing upcoming features).
141+
```markdown
142+
[PDF Accessibility](https://{{< prerelease-docs-url 1.9 >}}quarto.org/docs/output-formats/pdf-accessibility.html)
143+
```
144+
145+
The shortcode compares its version argument to the `version` key in `_quarto.yml` (which tracks the current stable release on `main`). If they match, docs are on quarto.org (`""`); if not, they're still on prerelease.quarto.org (`"prerelease."`). On the prerelease site (`prerelease-docs` profile), it always returns `"prerelease."`.
145146

146147
### Release lifecycle
147148

148149
1. **Development phase:** group is `[prerelease, rc]` — main site shows "Pre-release"
149150
2. **RC phase:** flip group to `[rc, prerelease]` — main site shows "Release Candidate"
150151
3. **Release:** flip back to `[prerelease, rc]` for the next development cycle
151152

152-
These flips only affect quarto.org. The prerelease site CI explicitly activates `prerelease,prerelease-docs`, so it always shows "Pre-release" regardless of group order.
153+
These flips only affect quarto.org. The prerelease site CI activates `prerelease-docs`, and the group order determines the phase branding on the prerelease site too.
153154

154155
### Local preview
155156

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
title: Prerelease Docs URL
2+
author: Quarto
3+
version: 0.0.1
4+
contributes:
5+
shortcodes:
6+
- prerelease-docs-url.lua
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
-- Version-aware shortcode for linking to prerelease docs.
2+
--
3+
-- Usage: {{< prerelease-docs-url 1.9 >}}
4+
--
5+
-- Returns "prerelease." when the referenced version's docs live on
6+
-- prerelease.quarto.org, or "" when they're on quarto.org.
7+
8+
local function handler(args, kwargs, meta, raw_args, context)
9+
local ref_version = quarto.shortcode.read_arg(args, 1)
10+
if ref_version == nil then
11+
return quarto.shortcode.error_output(
12+
"prerelease-docs-url",
13+
"requires a version argument, e.g. {{< prerelease-docs-url 1.9 >}}",
14+
context
15+
)
16+
end
17+
-- Strip surrounding quotes that may be preserved in text contexts
18+
ref_version = ref_version:gsub('^"(.*)"$', '%1'):gsub("^'(.*)'$", '%1')
19+
20+
-- On the prerelease site, always link to prerelease
21+
if quarto.project.profile:includes("prerelease-docs") then
22+
return pandoc.Str("prerelease.")
23+
end
24+
25+
-- Guard against missing or invalid version metadata
26+
local version_str = meta["version"] and pandoc.utils.stringify(meta["version"]) or nil
27+
if not version_str or version_str == "" then
28+
return quarto.shortcode.error_output(
29+
"prerelease-docs-url",
30+
"missing 'version' in document metadata",
31+
context
32+
)
33+
end
34+
35+
-- Compare referenced version to this branch's version using
36+
-- pandoc.types.Version for correct element-wise comparison (1.12 > 1.9)
37+
local ok_branch, branch_version = pcall(pandoc.types.Version, version_str)
38+
local ok_ref, ref = pcall(pandoc.types.Version, ref_version)
39+
40+
if not ok_branch then
41+
return quarto.shortcode.error_output(
42+
"prerelease-docs-url",
43+
"invalid metadata version '" .. version_str .. "'",
44+
context
45+
)
46+
end
47+
if not ok_ref then
48+
return quarto.shortcode.error_output(
49+
"prerelease-docs-url",
50+
"invalid version argument '" .. ref_version .. "'",
51+
context
52+
)
53+
end
54+
55+
if ref <= branch_version then
56+
return pandoc.Str("")
57+
else
58+
return pandoc.Str("prerelease.")
59+
end
60+
end
61+
62+
return {["prerelease-docs-url"] = handler}

_quarto-prerelease-docs.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Pre-release version number
2-
version: v1.9
2+
version: '1.9'
33

44
prerelease-subdomain: prerelease.
5-
prerelease-link-subdomain: prerelease.
65

76
website:
87
title: "Quarto (Pre-release)"
@@ -11,7 +10,7 @@ website:
1110
repo-branch: prerelease
1211
announcement:
1312
dismissable: false
14-
content: "Pre-release ({{< meta version >}}) Documentation: [Download {{< meta version >}}](/docs/download/prerelease.qmd), [Current Release Docs](http://quarto.org) "
13+
content: "Pre-release (v{{< meta version >}}) Documentation: [Download v{{< meta version >}}](/docs/download/prerelease.qmd), [Current Release Docs](http://quarto.org) "
1514
navbar:
1615
pinned: true
1716
search:

_quarto-rc.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
prerelease-title: Release Candidate
22
prerelease-lower: release candidate
33
prerelease-mode: Release Candidate
4-
prerelease-link-subdomain: prerelease.

_quarto.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,8 @@ filters:
712712
- at: post-quarto
713713
path: filters/include-dark.lua
714714

715+
version: '1.8'
715716
prerelease-subdomain: ''
716-
prerelease-link-subdomain: ''
717717

718718
freeze: true
719719

docs/blog/posts/2026-03-05-pdf-accessibility-and-standards/index.qmd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ Quarto's Markdown-based workflow handles many accessibility requirements automat
8383
But you do need to make sure your document has:
8484

8585
* A **title** in the YAML front matter.
86-
* **Alt text for every image**, specified with `fig-alt`. See [Figures](https://{{< meta prerelease-link-subdomain >}}quarto.org/docs/authoring/figures.html#alt-text) for details.
86+
* **Alt text for every image**, specified with `fig-alt`. See [Figures](https://{{< prerelease-docs-url 1.9 >}}quarto.org/docs/authoring/figures.html#alt-text) for details.
8787

88-
See the [LaTeX](https://{{< meta prerelease-link-subdomain >}}quarto.org/docs/output-formats/pdf-basics.html#accessibility-requirements) and [Typst](https://{{< meta prerelease-link-subdomain >}}quarto.org/docs/output-formats/typst.html#accessibility-requirements) documentation for more details.
88+
See the [LaTeX](https://{{< prerelease-docs-url 1.9 >}}quarto.org/docs/output-formats/pdf-basics.html#accessibility-requirements) and [Typst](https://{{< prerelease-docs-url 1.9 >}}quarto.org/docs/output-formats/typst.html#accessibility-requirements) documentation for more details.
8989

9090
## If your document fails validation
9191

@@ -101,7 +101,7 @@ We ran our test suite -- 188 LaTeX examples and 317 Typst examples -- to find wh
101101

102102
Margin content is the biggest structural blocker. If you use `.column-margin` divs, `cap-location: margin`, `reference-location: margin`, or `citation-location: margin`, the resulting PDF will not pass UA-2. The underlying `sidenotes` and `marginnote` LaTeX packages [do not cooperate with PDF tagging](https://github.com/quarto-dev/quarto-cli/issues/14103).
103103

104-
(Margin content does work with Typst and passes UA-1 -- see [Typst Article Layout](https://{{< meta prerelease-link-subdomain >}}quarto.org/docs/output-formats/typst.html#article-layout).)
104+
(Margin content does work with Typst and passes UA-1 -- see [Typst Article Layout](https://{{< prerelease-docs-url 1.9 >}}quarto.org/docs/output-formats/typst.html#article-layout).)
105105

106106
There are smaller upstream issues in Pandoc, LaTeX, and LaTeX packages, [documented here](https://github.com/quarto-dev/quarto-cli/pull/14097#issuecomment-3947653207).
107107

@@ -111,7 +111,7 @@ In our tests, Typst catches every UA-1 violation, and fails to generate the PDF.
111111

112112
Typst also seems to do a very good job of generating UA-1 compliant output by default -- almost all errors were due to missing titles or missing alt text.
113113

114-
However, we did discover that [Typst books](https://{{< meta prerelease-link-subdomain >}}quarto.org/docs/books/book-output.html#typst-output) are not yet compliant. There is a [structural problem with the Typst orange-book package](https://github.com/flavio20002/typst-orange-template/issues/38) and we'll work with the maintainers to correct it.
114+
However, we did discover that [Typst books](https://{{< prerelease-docs-url 1.9 >}}quarto.org/docs/books/book-output.html#typst-output) are not yet compliant. There is a [structural problem with the Typst orange-book package](https://github.com/flavio20002/typst-orange-template/issues/38) and we'll work with the maintainers to correct it.
115115

116116
## Conclusion
117117

0 commit comments

Comments
 (0)