Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion news/changelog-1.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,13 @@ All changes included in 1.7:
- ([#12365](https://github.com/quarto-dev/quarto-cli/pull/12365)): `brand color` shortcode takes an optional `brandMode` second parameter, default `light`.
- ([#12453](https://github.com/quarto-dev/quarto-cli/issues/12453)): Expose `_quarto.modules.brand` as `quarto.brand` and add `has_mode()` function.

## Lua API
### Conditional Content

- ([#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`).

### Quarto Lua API

- ([#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`)
- ([#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).

## Languages
Expand Down
4 changes: 2 additions & 2 deletions src/resources/filters/customnodes/content-hidden.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ function propertiesMatch(properties, profiles)
local tests = {
{ constants.kWhenMeta, check_meta, false },
{ constants.kUnlessMeta, check_meta, true },
{ constants.kWhenFormat, _quarto.format.isFormat, false },
{ constants.kUnlessFormat, _quarto.format.isFormat, true },
{ constants.kWhenFormat, quarto.format.is_format, false },
{ constants.kUnlessFormat, quarto.format.is_format, true },
{ constants.kWhenProfile, check_profile, false },
{ constants.kUnlessProfile, check_profile, true }
}
Expand Down
18 changes: 17 additions & 1 deletion src/resources/pandoc/datadir/_format.lua
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,22 @@ local function _main()
return isMarkdownOutput()
elseif to == "asciidoc" or to == "asciidoctor" then
return isAsciiDocOutput()
elseif to == "confluence" then
return isConfluenceOutput()
elseif to == "docusaurus" or to == "docusaurus-md" then
return isDocusaurusOutput()
elseif to == "email" then
return isEmailOutput()
elseif to == "dashboard" then
return isDashboardOutput()
elseif to == "gfm" then
return isGithubMarkdownOutput()
elseif to == "hugo-md" or to == 'hugo' then
return isHugoMarkdownOutput()
--[[ Not working yet
elseif to == "ipynb" then
return isIpynbOutput()
]]--
else
return false
end
Expand All @@ -279,7 +295,7 @@ local function _main()
isRawLatex = isRawLatex,
is_raw_latex = isRawLatex,
isFormat = isFormat,
is_format = is_format,
is_format = isFormat,
isLatexOutput = isLatexOutput,
is_latex_output = isLatexOutput,
isBeamerOutput = isBeamerOutput,
Expand Down
4 changes: 2 additions & 2 deletions tests/docs/smoke-all/2023/09/22/beamer-numsec.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ title: Number Sections
format:
beamer:
number-sections: true
output-ext: tex
keep-tex: true
_quarto:
tests:
beamer:
ensureFileRegexMatches:
ensureLatexFileRegexMatches:
- ['\{1 Section\}', '\{1[.]1 Subsection\}']
- []
---
Expand Down
171 changes: 171 additions & 0 deletions tests/docs/smoke-all/conditional-content/when-format.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
---
title: Testing when-format
keep-tex: true
keep-typ: true
_quarto:
tests:
latex:
ensureFileRegexMatches:
- ['Only visible in LATEX']
- ['Only visible in (?!LATEX|PDF)']
pdf:
ensureLatexFileRegexMatches:
- ['Only visible in LATEX', 'Only visible in PDF']
- ['Only visible in (?!LATEX|PDF)']
html:
ensureFileRegexMatches:
- ['Only visible in HTML', 'Only visible in HTMLJS']
- ['Only visible in (?!HTML)']
revealjs:
ensureFileRegexMatches:
- ['Only visible in HTML', 'Only visible in HTMLJS', 'Only visible in REVEALJS']
- ['Only visible in (?!HTML|REVEALJS)']

typst:
ensureTypstFileRegexMatches:
- ['Only visible in TYPST']
- ['Only visible in (?!TYPST)']
docx:
ensureDocxRegexMatches:
- ['Only visible in DOCX']
- ['Only visible in (?!DOCX)']
pptx:
ensurePptxRegexMatches:
- ['Only visible in PPTX']
- 2
docusaurus-md:
ensureFileRegexMatches:
- ['Only visible in DOCUSAURUS', 'Only visible in DOCUSAURUSMD', 'Only visible in MARKDOWN']
- ['Only visible in (?!DOCUSAURUS|MARKDOWN)']
hugo-md:
ensureFileRegexMatches:
- ['Only visible in HUGO', 'Only visible in MARKDOWN', 'Only visible in HUGOMD']
- ['Only visible in (?!HUGO|MARKDOWN)']
gfm:
ensureFileRegexMatches:
- ['Only visible in GFM', 'Only visible in MARKDOWN', 'Only visible in COMMONMARK']
- ['Only visible in (?!GFM|MARKDOWN|COMMONMARK)']
commonmark:
ensureFileRegexMatches:
- ['Only visible in COMMONMARK', 'Only visible in MARKDOWN']
- ['Only visible in (?!GFM|MARKDOWN|COMMONMARK)']
markdown:
ensureFileRegexMatches:
- ['Only visible in MARKDOWN']
- ['Only visible in (?!MARKDOWN)']
confluence-publish:
ensureFileRegexMatches:
- ['Only visible in CONFLUENCE']
- ['Only visible in (?!CONFLUENCE)']
asciidoc:
ensureFileRegexMatches:
- ['Only visible in ASCIIDOC']
- ['Only visible in (?!ASCIIDOC)']
dashboard:
ensureFileRegexMatches:
- ['Only visible in DASHBOARD', 'Only visible in HTML', 'Only visible in HTMLJS']
- ['Only visible in (?!HTML|DASHBOARD)']
email:
ensureFileRegexMatches:
- ['Only visible in EMAIL', 'Only visible in HTML', 'Only visible in HTMLJS']
- ['Only visible in (?!HTML|EMAIL)']
ipynb:
ensureFileRegexMatches:
- ['Only visible in IPYNB']
- ['Only visible in (?!IPYNB)']
beamer:
ensureLatexFileRegexMatches:
- ['Only visible in BEAMER', 'Only visible in LATEX', 'Only visible in PDF']
- ['Only visible in (?!BEAMER|LATEX|PDF)']
---

::: {.content-visible when-format="html"}
Only visible in HTML
:::

::: {.content-visible when-format="revealjs"}
Only visible in REVEALJS
:::

::: {.content-visible when-format="html:js"}
Only visible in HTMLJS
:::

::: {.content-visible when-format="latex"}
Only visible in LATEX
:::

::: {.content-visible when-format="pdf"}
Only visible in PDF
:::

::: {.content-visible when-format="typst"}
Only visible in TYPST
:::

::: {.content-visible when-format="docx"}
Only visible in DOCX
:::

::: {.content-visible when-format="pptx"}
Only visible in PPTX
:::

::: {.content-visible when-format="epub"}
Only visible in EPUB
:::

::: {.content-visible when-format="markdown"}
Only visible in MARKDOWN
:::

::: {.content-visible when-format="gfm"}
Only visible in GFM
:::

::: {.content-visible when-format="commonmark"}
Only visible in COMMONMARK
:::

::: {.content-visible when-format="asciidoc"}
Only visible in ASCIIDOC
:::

::: {.content-visible when-format="docusaurus"}
Only visible in DOCUSAURUS
:::

::: {.content-visible when-format="docusaurus-md"}
Only visible in DOCUSAURUSMD
:::

::: {.content-visible when-format="hugo"}
Only visible in HUGO
:::

::: {.content-visible when-format="hugo-md"}
Only visible in HUGOMD
:::

::: {.content-visible when-format="confluence"}
Only visible in CONFLUENCE
:::

::: {.content-visible when-format="dashboard"}
Only visible in DASHBOARD
:::

::: {.content-visible when-format="email"}
Only visible in EMAIL
:::

::: {.content-visible when-format="ipynb"}
Only visible in IPYNB
:::

::: {.content-visible when-format="beamer"}
Only visible in BEAMER
:::



5 changes: 4 additions & 1 deletion tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ export function outputForInput(
outputExt = ext
} else {
outputExt = baseFormat || "html";
if (baseFormat === "latex" || baseFormat == "context" || baseFormat == "beamer") {
if (baseFormat === "latex" || baseFormat == "context") {
outputExt = "tex";
}
if (baseFormat === "beamer") {
outputExt = "pdf";
}
if (baseFormat === "revealjs") {
outputExt = "html";
}
Expand Down
4 changes: 2 additions & 2 deletions tests/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { readYamlFromString } from "../src/core/yaml.ts";
import { ExecuteOutput, Verify } from "./test.ts";
import { outputForInput } from "./utils.ts";
import { unzip } from "../src/core/zip.ts";
import { dirAndStem, which } from "../src/core/path.ts";
import { dirAndStem, safeRemoveSync, which } from "../src/core/path.ts";
import { isWindows } from "../src/deno_ral/platform.ts";
import { execProcess } from "../src/core/process.ts";
import { canonicalizeSnapshot, checkSnapshot } from "./verify-snapshot.ts";
Expand Down Expand Up @@ -488,7 +488,7 @@ export const verifyKeepFileRegexMatches = (
try {
await regexChecker(file, matches, noMatches);
} finally {
await Deno.remove(file);
await safeRemoveSync(file);
}
}
return verifyFileRegexMatches(keptFileChecker, `Inspecting intermediate ${keptFile} for Regex matches`)(keptFile, matchesUntyped, noMatchesUntyped);
Expand Down
Loading