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
3 changes: 2 additions & 1 deletion news/changelog-1.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ All changes included in 1.6:
- ([#10858](https://github.com/quarto-dev/quarto-cli/issues/10858)): Don't crash in `gfm` when `content` of a `FloatRefTarget` is of type `Blocks`.
- ([#10894](https://github.com/quarto-dev/quarto-cli/issues/10894)): Fix configuration of title and prefix in callouts for `html`, `revealjs`, `pdf`, and `typst`.
- ([#10999](https://github.com/quarto-dev/quarto-cli/issues/10999)): New API entry point: `quarto.paths.rscript()` to resolve `Rscript` path in Lua filters and extensions consistently with Quarto itself.
- ([#11124](https://github.com/quarto-dev/quarto-cli/pull/11124)): Sort keys when encoding tables as JSON
- ([#11124](https://github.com/quarto-dev/quarto-cli/pull/11124)): Sort keys when encoding tables as JSON.
- ([#11303](https://github.com/quarto-dev/quarto-cli/issues/11303)): Fix conditional content for divs with repeated attributes.

## `dashboard` Format

Expand Down
61 changes: 40 additions & 21 deletions src/resources/filters/customnodes/content-hidden.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ _quarto.ast.add_handler({
error("Ignoring invalid condition in conditional block: " .. v[1])
-- luacov: enable
else
result.condition[v[1]] = v[2]
if result.condition[v[1]] == nil then
result.condition[v[1]] = pandoc.List({})
end
result.condition[v[1]]:insert(v[2])
end
end

Expand Down Expand Up @@ -152,30 +155,46 @@ end
-- "properties" here will come either from "conditions", in the case of a custom AST node
-- or from the attributes of the element itself in the case of spans or codeblocks
function propertiesMatch(properties, profiles)
local match = true
if properties[constants.kWhenMeta] ~= nil then
local v = properties[constants.kWhenMeta]
v = split(v, ".") or { v }
local r = get_meta(v)
match = match and (type(r) == "boolean" and r)
end
if properties[constants.kUnlessMeta] ~= nil then
local v = properties[constants.kUnlessMeta]
v = split(v, ".") or { v }
local function check_meta(v)
local v = split(v, ".") or { v }
local r = get_meta(v)
match = match and not (type(r) == "boolean" and r)
return type(r) == "boolean" and r
end
if properties[constants.kWhenFormat] ~= nil then
match = match and _quarto.format.isFormat(properties[constants.kWhenFormat])
local function check_profile(value)
return profiles:includes(value)
end
if properties[constants.kUnlessFormat] ~= nil then
match = match and not _quarto.format.isFormat(properties[constants.kUnlessFormat])
end
if properties[constants.kWhenProfile] ~= nil then
match = match and profiles:includes(properties[constants.kWhenProfile])
local function check_property(key, f)
local v = properties[key]
if type(v) == "string" then
return f(v)
elseif type(v) == "table" then
local r = false
for _, value in ipairs(v) do
r = r or f(value)
end
return r
else
-- luacov: disable
error("Invalid value type for condition: " .. type(v))
-- luacov: enable
end
end
if properties[constants.kUnlessProfile] ~= nil then
match = match and not profiles:includes(properties[constants.kUnlessProfile])
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.kWhenProfile, check_profile, false },
{ constants.kUnlessProfile, check_profile, true }
}
local match = true
for _, test in ipairs(tests) do
local key = test[1]
local f = test[2]
local invert = test[3]
if properties[key] ~= nil then
match = match and (invert ~= check_property(key, f))
end
end
return match
end
Expand Down
15 changes: 15 additions & 0 deletions tests/docs/smoke-all/2024/11/04/issue-11303.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
format: html
_quarto:
tests:
html:
ensureFileRegexMatches:
- ["38ea19c4-c121-43c3-9f6c-632e938d9332"]
- []
---

::: {.content-visible when-format="html" when-format="pdf"}

38ea19c4-c121-43c3-9f6c-632e938d9332

:::
Loading