Skip to content

Commit 853f463

Browse files
committed
feat(revealjs): add tabset-fragments option
Step through the tabs of a tabset as fragments when `tabset-fragments` is on, or when a tabset has the `.tabset-fragments` class. The `.no-tabset-fragments` class opts one tabset out. The plugin gives the slide one fragment order, so incremental lists, stepped code highlights and explicit fragment indices do not collide with the tabs. The shown tab follows the fragment state after going back, a deep link, a click or in scroll view, and tab switches go through tabby. In PDF, each step gets a page, or each tab state gets one with `pdf-separate-fragments: false`.
1 parent f6626b1 commit 853f463

24 files changed

Lines changed: 2510 additions & 11 deletions

‎news/changelog-1.12.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ All changes included in 1.12:
2828
### `revealjs`
2929

3030
- ([#7378](https://github.com/quarto-dev/quarto-cli/issues/7378)): Add `code-line-fragment-indices` to set the fragment index of each step of stepped `code-line-numbers` highlighting. (author: @mcanouil)
31+
- ([#15332](https://github.com/quarto-dev/quarto-cli/pull/15332)): Add `tabset-fragments` option for `revealjs` presentations to step through the tabs of a tabset as fragments, so that a PDF print shows every tab. Use the `.tabset-fragments` and `.no-tabset-fragments` classes to turn it on or off for one tabset. (author: @mcanouil)
3132

3233
### `typst`
3334

‎src/format/reveal/constants.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const kRevealJsConfig = "revealjs-config";
1010
export const kSlideLogo = "logo";
1111
export const kSlideFooter = "footer";
1212
export const kHashType = "hash-type";
13+
export const kTabsetFragments = "tabset-fragments";
1314
export const kScrollable = "scrollable";
1415
export const kSmaller = "smaller";
1516
export const kCenter = "center";

‎src/format/reveal/format-reveal-plugin.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { formatResourcePath } from "../../core/resources.ts";
2828
import { TempContext } from "../../core/temp.ts";
2929
import { optionsToKebab, revealMetadataFilter } from "./metadata.ts";
3030
import { revealMultiplexPlugin } from "./format-reveal-multiplex.ts";
31+
import { kTabsetFragments } from "./constants.ts";
3132
import { isSelfContained } from "../../command/render/render-info.ts";
3233

3334
import { readAndValidateYamlFromFile } from "../../core/schema/validated-yaml.ts";
@@ -98,8 +99,32 @@ export function isPluginBundle(
9899
return (plugin as RevealPluginBundle).plugin !== undefined;
99100
}
100101

102+
const kTabsetFragmentsClass = /(^|[\s{])\.tabset-fragments(?=[\s}])/m;
103+
104+
export function hasTabsetFragmentsClass(markdown: string): boolean {
105+
return kTabsetFragmentsClass.test(markdown);
106+
}
107+
108+
export function revealTabsetFragmentsPlugin(
109+
format: Format,
110+
markdown: string,
111+
): RevealPluginBundle | undefined {
112+
const deckOn = format.metadata[kTabsetFragments] === true;
113+
if (deckOn || hasTabsetFragmentsClass(markdown)) {
114+
return {
115+
plugin: formatResourcePath(
116+
"revealjs",
117+
join("plugins", "tabset-fragments"),
118+
),
119+
config: { tabsetFragments: deckOn },
120+
};
121+
}
122+
return undefined;
123+
}
124+
101125
export async function revealPluginExtras(
102126
input: string,
127+
markdown: string,
103128
format: Format,
104129
flags: PandocFlags,
105130
temp: TempContext,
@@ -153,6 +178,12 @@ export async function revealPluginExtras(
153178
pluginBundles.push(multiplexPlugin);
154179
}
155180

181+
// tabset fragments plugin (optional)
182+
const tabsetFragmentsPlugin = revealTabsetFragmentsPlugin(format, markdown);
183+
if (tabsetFragmentsPlugin) {
184+
pluginBundles.push(tabsetFragmentsPlugin);
185+
}
186+
156187
const resolvePluginPath = async (plugin: string) => {
157188
// Look for an extension
158189
let extensions = await extensionContext?.find(

‎src/format/reveal/format-reveal.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export function revealjsFormat() {
159159
formatPreviewFile: revealMuliplexPreviewFile,
160160
formatExtras: async (
161161
input: string,
162-
_markdown: string,
162+
markdown: string,
163163
flags: PandocFlags,
164164
format: Format,
165165
libDir: string,
@@ -224,6 +224,7 @@ export function revealjsFormat() {
224224

225225
const revealPluginData = await revealPluginExtras(
226226
input,
227+
markdown,
227228
format,
228229
flags,
229230
services.temp,

‎src/resources/editor/tools/vs-code.mjs‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19102,6 +19102,17 @@ var init_yaml_intelligence_resources = __esm({
1910219102
long: "Footer to include on all slides. Can also be set per-slide by including a\ndiv with class `.footer` on the slide.\n"
1910319103
}
1910419104
},
19105+
{
19106+
name: "tabset-fragments",
19107+
tags: {
19108+
formats: [
19109+
"revealjs"
19110+
]
19111+
},
19112+
schema: "boolean",
19113+
default: false,
19114+
description: "Step through the tabs of each tabset as fragments.\nUse the `.tabset-fragments` or `.no-tabset-fragments` class on a tabset to turn it on or off for that tabset.\nA tabset inside a tabset that does not step does not step either.\n"
19115+
},
1910519116
{
1910619117
name: "scrollable",
1910719118
tags: {
@@ -24720,6 +24731,7 @@ var init_yaml_intelligence_resources = __esm({
2472024731
short: "Footer to include on all slides",
2472124732
long: "Footer to include on all slides. Can also be set per-slide by\nincluding a div with class <code>.footer</code> on the slide."
2472224733
},
24734+
"Step through the tabs of each tabset as fragments. Use the\n<code>.tabset-fragments</code> or <code>.no-tabset-fragments</code>\nclass on a tabset to turn it on or off for that tabset. A tabset inside\na tabset that does not step does not step either.",
2472324735
{
2472424736
short: "Allow content that overflows slides vertically to scroll",
2472524737
long: "<code>true</code> to allow content that overflows slides vertically\nto scroll. This can also be set per-slide by including the\n<code>.scrollable</code> class on the slide title."
@@ -25909,12 +25921,12 @@ var init_yaml_intelligence_resources = __esm({
2590925921
mermaid: "%%"
2591025922
},
2591125923
"handlers/mermaid/schema.yml": {
25912-
_internalId: 222313,
25924+
_internalId: 222475,
2591325925
type: "object",
2591425926
description: "be an object",
2591525927
properties: {
2591625928
"mermaid-format": {
25917-
_internalId: 222305,
25929+
_internalId: 222467,
2591825930
type: "enum",
2591925931
enum: [
2592025932
"png",
@@ -25930,7 +25942,7 @@ var init_yaml_intelligence_resources = __esm({
2593025942
exhaustiveCompletions: true
2593125943
},
2593225944
theme: {
25933-
_internalId: 222312,
25945+
_internalId: 222474,
2593425946
type: "anyOf",
2593525947
anyOf: [
2593625948
{

‎src/resources/editor/tools/yaml/all-schema-definitions.json‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎src/resources/editor/tools/yaml/web-worker.js‎

Lines changed: 15 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/resources/editor/tools/yaml/yaml-intelligence-resources.json‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12075,6 +12075,17 @@
1207512075
"long": "Footer to include on all slides. Can also be set per-slide by including a\ndiv with class `.footer` on the slide.\n"
1207612076
}
1207712077
},
12078+
{
12079+
"name": "tabset-fragments",
12080+
"tags": {
12081+
"formats": [
12082+
"revealjs"
12083+
]
12084+
},
12085+
"schema": "boolean",
12086+
"default": false,
12087+
"description": "Step through the tabs of each tabset as fragments.\nUse the `.tabset-fragments` or `.no-tabset-fragments` class on a tabset to turn it on or off for that tabset.\nA tabset inside a tabset that does not step does not step either.\n"
12088+
},
1207812089
{
1207912090
"name": "scrollable",
1208012091
"tags": {
@@ -17693,6 +17704,7 @@
1769317704
"short": "Footer to include on all slides",
1769417705
"long": "Footer to include on all slides. Can also be set per-slide by\nincluding a div with class <code>.footer</code> on the slide."
1769517706
},
17707+
"Step through the tabs of each tabset as fragments. Use the\n<code>.tabset-fragments</code> or <code>.no-tabset-fragments</code>\nclass on a tabset to turn it on or off for that tabset. A tabset inside\na tabset that does not step does not step either.",
1769617708
{
1769717709
"short": "Allow content that overflows slides vertically to scroll",
1769817710
"long": "<code>true</code> to allow content that overflows slides vertically\nto scroll. This can also be set per-slide by including the\n<code>.scrollable</code> class on the slide title."
@@ -18882,12 +18894,12 @@
1888218894
"mermaid": "%%"
1888318895
},
1888418896
"handlers/mermaid/schema.yml": {
18885-
"_internalId": 222313,
18897+
"_internalId": 222475,
1888618898
"type": "object",
1888718899
"description": "be an object",
1888818900
"properties": {
1888918901
"mermaid-format": {
18890-
"_internalId": 222305,
18902+
"_internalId": 222467,
1889118903
"type": "enum",
1889218904
"enum": [
1889318905
"png",
@@ -18903,7 +18915,7 @@
1890318915
"exhaustiveCompletions": true
1890418916
},
1890518917
"theme": {
18906-
"_internalId": 222312,
18918+
"_internalId": 222474,
1890718919
"type": "anyOf",
1890818920
"anyOf": [
1890918921
{
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name: QuartoTabsetFragments
2+
script: tabset-fragments.js

0 commit comments

Comments
 (0)