Skip to content

Commit 6f7568b

Browse files
authored
Merge pull request #12462 from quarto-dev/when-format-more
2 parents 70d973d + 42057fb commit 6f7568b

File tree

7 files changed

+204
-9
lines changed

7 files changed

+204
-9
lines changed

news/changelog-1.7.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,13 @@ All changes included in 1.7:
154154
- ([#12365](https://github.com/quarto-dev/quarto-cli/pull/12365)): `brand color` shortcode takes an optional `brandMode` second parameter, default `light`.
155155
- ([#12453](https://github.com/quarto-dev/quarto-cli/issues/12453)): Expose `_quarto.modules.brand` as `quarto.brand` and add `has_mode()` function.
156156

157-
## Lua API
157+
### Conditional Content
158158

159+
- ([#4411](https://github.com/quarto-dev/quarto-cli/issues/12462)): Added support for new format and aliases in `when-format` and `unless-format`: `confluence`, `docusaurus` (and `docusaurus-md`), `email`, `dashboard`, `gfm`, `hugo` (and `hugo-md`).
160+
161+
### Quarto Lua API
162+
163+
- ([#4411](https://github.com/quarto-dev/quarto-cli/issues/12462)): `quarto.format.is_format` is now working as expected with support of more aliases: `confluence`, `docusaurus` (and `docusaurus-md`), `email`, `dashboard`, `gfm`, `hugo` (and `hugo-md`)
159164
- ([#12299](https://github.com/quarto-dev/quarto-cli/issues/12299)): `quarto.doc.pdf_engine()` now correctly returns the PDF engine used for the document. `quarto.doc.cite_method()` now returns `nil` if no citation method will be used (i.e. no references is the document set).
160165

161166
## Languages

src/resources/filters/customnodes/content-hidden.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ function propertiesMatch(properties, profiles)
183183
local tests = {
184184
{ constants.kWhenMeta, check_meta, false },
185185
{ constants.kUnlessMeta, check_meta, true },
186-
{ constants.kWhenFormat, _quarto.format.isFormat, false },
187-
{ constants.kUnlessFormat, _quarto.format.isFormat, true },
186+
{ constants.kWhenFormat, quarto.format.is_format, false },
187+
{ constants.kUnlessFormat, quarto.format.is_format, true },
188188
{ constants.kWhenProfile, check_profile, false },
189189
{ constants.kUnlessProfile, check_profile, true }
190190
}

src/resources/pandoc/datadir/_format.lua

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,22 @@ local function _main()
265265
return isMarkdownOutput()
266266
elseif to == "asciidoc" or to == "asciidoctor" then
267267
return isAsciiDocOutput()
268+
elseif to == "confluence" then
269+
return isConfluenceOutput()
270+
elseif to == "docusaurus" or to == "docusaurus-md" then
271+
return isDocusaurusOutput()
272+
elseif to == "email" then
273+
return isEmailOutput()
274+
elseif to == "dashboard" then
275+
return isDashboardOutput()
276+
elseif to == "gfm" then
277+
return isGithubMarkdownOutput()
278+
elseif to == "hugo-md" or to == 'hugo' then
279+
return isHugoMarkdownOutput()
280+
--[[ Not working yet
281+
elseif to == "ipynb" then
282+
return isIpynbOutput()
283+
]]--
268284
else
269285
return false
270286
end
@@ -279,7 +295,7 @@ local function _main()
279295
isRawLatex = isRawLatex,
280296
is_raw_latex = isRawLatex,
281297
isFormat = isFormat,
282-
is_format = is_format,
298+
is_format = isFormat,
283299
isLatexOutput = isLatexOutput,
284300
is_latex_output = isLatexOutput,
285301
isBeamerOutput = isBeamerOutput,

tests/docs/smoke-all/2023/09/22/beamer-numsec.qmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ title: Number Sections
33
format:
44
beamer:
55
number-sections: true
6-
output-ext: tex
6+
keep-tex: true
77
_quarto:
88
tests:
99
beamer:
10-
ensureFileRegexMatches:
10+
ensureLatexFileRegexMatches:
1111
- ['\{1 Section\}', '\{1[.]1 Subsection\}']
1212
- []
1313
---
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
---
2+
title: Testing when-format
3+
keep-tex: true
4+
keep-typ: true
5+
_quarto:
6+
tests:
7+
latex:
8+
ensureFileRegexMatches:
9+
- ['Only visible in LATEX']
10+
- ['Only visible in (?!LATEX|PDF)']
11+
pdf:
12+
ensureLatexFileRegexMatches:
13+
- ['Only visible in LATEX', 'Only visible in PDF']
14+
- ['Only visible in (?!LATEX|PDF)']
15+
html:
16+
ensureFileRegexMatches:
17+
- ['Only visible in HTML', 'Only visible in HTMLJS']
18+
- ['Only visible in (?!HTML)']
19+
revealjs:
20+
ensureFileRegexMatches:
21+
- ['Only visible in HTML', 'Only visible in HTMLJS', 'Only visible in REVEALJS']
22+
- ['Only visible in (?!HTML|REVEALJS)']
23+
24+
typst:
25+
ensureTypstFileRegexMatches:
26+
- ['Only visible in TYPST']
27+
- ['Only visible in (?!TYPST)']
28+
docx:
29+
ensureDocxRegexMatches:
30+
- ['Only visible in DOCX']
31+
- ['Only visible in (?!DOCX)']
32+
pptx:
33+
ensurePptxRegexMatches:
34+
- ['Only visible in PPTX']
35+
- 2
36+
docusaurus-md:
37+
ensureFileRegexMatches:
38+
- ['Only visible in DOCUSAURUS', 'Only visible in DOCUSAURUSMD', 'Only visible in MARKDOWN']
39+
- ['Only visible in (?!DOCUSAURUS|MARKDOWN)']
40+
hugo-md:
41+
ensureFileRegexMatches:
42+
- ['Only visible in HUGO', 'Only visible in MARKDOWN', 'Only visible in HUGOMD']
43+
- ['Only visible in (?!HUGO|MARKDOWN)']
44+
gfm:
45+
ensureFileRegexMatches:
46+
- ['Only visible in GFM', 'Only visible in MARKDOWN', 'Only visible in COMMONMARK']
47+
- ['Only visible in (?!GFM|MARKDOWN|COMMONMARK)']
48+
commonmark:
49+
ensureFileRegexMatches:
50+
- ['Only visible in COMMONMARK', 'Only visible in MARKDOWN']
51+
- ['Only visible in (?!GFM|MARKDOWN|COMMONMARK)']
52+
markdown:
53+
ensureFileRegexMatches:
54+
- ['Only visible in MARKDOWN']
55+
- ['Only visible in (?!MARKDOWN)']
56+
confluence-publish:
57+
ensureFileRegexMatches:
58+
- ['Only visible in CONFLUENCE']
59+
- ['Only visible in (?!CONFLUENCE)']
60+
asciidoc:
61+
ensureFileRegexMatches:
62+
- ['Only visible in ASCIIDOC']
63+
- ['Only visible in (?!ASCIIDOC)']
64+
dashboard:
65+
ensureFileRegexMatches:
66+
- ['Only visible in DASHBOARD', 'Only visible in HTML', 'Only visible in HTMLJS']
67+
- ['Only visible in (?!HTML|DASHBOARD)']
68+
email:
69+
ensureFileRegexMatches:
70+
- ['Only visible in EMAIL', 'Only visible in HTML', 'Only visible in HTMLJS']
71+
- ['Only visible in (?!HTML|EMAIL)']
72+
ipynb:
73+
ensureFileRegexMatches:
74+
- ['Only visible in IPYNB']
75+
- ['Only visible in (?!IPYNB)']
76+
beamer:
77+
ensureLatexFileRegexMatches:
78+
- ['Only visible in BEAMER', 'Only visible in LATEX', 'Only visible in PDF']
79+
- ['Only visible in (?!BEAMER|LATEX|PDF)']
80+
---
81+
82+
::: {.content-visible when-format="html"}
83+
Only visible in HTML
84+
:::
85+
86+
::: {.content-visible when-format="revealjs"}
87+
Only visible in REVEALJS
88+
:::
89+
90+
::: {.content-visible when-format="html:js"}
91+
Only visible in HTMLJS
92+
:::
93+
94+
::: {.content-visible when-format="latex"}
95+
Only visible in LATEX
96+
:::
97+
98+
::: {.content-visible when-format="pdf"}
99+
Only visible in PDF
100+
:::
101+
102+
::: {.content-visible when-format="typst"}
103+
Only visible in TYPST
104+
:::
105+
106+
::: {.content-visible when-format="docx"}
107+
Only visible in DOCX
108+
:::
109+
110+
::: {.content-visible when-format="pptx"}
111+
Only visible in PPTX
112+
:::
113+
114+
::: {.content-visible when-format="epub"}
115+
Only visible in EPUB
116+
:::
117+
118+
::: {.content-visible when-format="markdown"}
119+
Only visible in MARKDOWN
120+
:::
121+
122+
::: {.content-visible when-format="gfm"}
123+
Only visible in GFM
124+
:::
125+
126+
::: {.content-visible when-format="commonmark"}
127+
Only visible in COMMONMARK
128+
:::
129+
130+
::: {.content-visible when-format="asciidoc"}
131+
Only visible in ASCIIDOC
132+
:::
133+
134+
::: {.content-visible when-format="docusaurus"}
135+
Only visible in DOCUSAURUS
136+
:::
137+
138+
::: {.content-visible when-format="docusaurus-md"}
139+
Only visible in DOCUSAURUSMD
140+
:::
141+
142+
::: {.content-visible when-format="hugo"}
143+
Only visible in HUGO
144+
:::
145+
146+
::: {.content-visible when-format="hugo-md"}
147+
Only visible in HUGOMD
148+
:::
149+
150+
::: {.content-visible when-format="confluence"}
151+
Only visible in CONFLUENCE
152+
:::
153+
154+
::: {.content-visible when-format="dashboard"}
155+
Only visible in DASHBOARD
156+
:::
157+
158+
::: {.content-visible when-format="email"}
159+
Only visible in EMAIL
160+
:::
161+
162+
::: {.content-visible when-format="ipynb"}
163+
Only visible in IPYNB
164+
:::
165+
166+
::: {.content-visible when-format="beamer"}
167+
Only visible in BEAMER
168+
:::
169+
170+
171+

tests/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,12 @@ export function outputForInput(
109109
outputExt = ext
110110
} else {
111111
outputExt = baseFormat || "html";
112-
if (baseFormat === "latex" || baseFormat == "context" || baseFormat == "beamer") {
112+
if (baseFormat === "latex" || baseFormat == "context") {
113113
outputExt = "tex";
114114
}
115+
if (baseFormat === "beamer") {
116+
outputExt = "pdf";
117+
}
115118
if (baseFormat === "revealjs") {
116119
outputExt = "html";
117120
}

tests/verify.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { readYamlFromString } from "../src/core/yaml.ts";
1717
import { ExecuteOutput, Verify } from "./test.ts";
1818
import { outputForInput } from "./utils.ts";
1919
import { unzip } from "../src/core/zip.ts";
20-
import { dirAndStem, which } from "../src/core/path.ts";
20+
import { dirAndStem, safeRemoveSync, which } from "../src/core/path.ts";
2121
import { isWindows } from "../src/deno_ral/platform.ts";
2222
import { execProcess } from "../src/core/process.ts";
2323
import { canonicalizeSnapshot, checkSnapshot } from "./verify-snapshot.ts";
@@ -488,7 +488,7 @@ export const verifyKeepFileRegexMatches = (
488488
try {
489489
await regexChecker(file, matches, noMatches);
490490
} finally {
491-
await Deno.remove(file);
491+
await safeRemoveSync(file);
492492
}
493493
}
494494
return verifyFileRegexMatches(keptFileChecker, `Inspecting intermediate ${keptFile} for Regex matches`)(keptFile, matchesUntyped, noMatchesUntyped);

0 commit comments

Comments
 (0)