@@ -10,6 +10,19 @@ local kWhenProfile = "when-profile"
1010local kUnlessProfile = " unless-profile"
1111local kConditions = pandoc .List ({kWhenFormat , kUnlessFormat , kWhenProfile , kUnlessProfile })
1212
13+ function is_visible (node )
14+ local profiles = pandoc .List (param (" quarto_profile" , {}))
15+ local match = propertiesMatch (node .condition , profiles )
16+ if node .behavior == kContentVisible then
17+ return match
18+ elseif node .behavior == kContentHidden then
19+ return not match
20+ else
21+ crash_with_stack_trace ()
22+ return false
23+ end
24+ end
25+
1326_quarto .ast .add_handler ({
1427 class_name = { kContentVisible , kContentHidden },
1528
@@ -39,21 +52,13 @@ _quarto.ast.add_handler({
3952
4053 render = function (node )
4154 local el = node .node
42- local profiles = pandoc .List (param (" quarto_profile" , {}))
43- local visible
44- if node .behavior == kContentVisible then
45- clearHiddenVisibleAttributes (el )
46- visible = propertiesMatch (node .condition , profiles )
47- elseif node .behavior == kContentHidden then
48- clearHiddenVisibleAttributes (el )
49- visible = not propertiesMatch (node .condition , profiles )
50- else
51- crash_with_stack_trace ()
52- end
55+ local visible = is_visible (node )
56+ clearHiddenVisibleAttributes (el )
5357 if visible then
5458 return el .content
59+ else
60+ return {}
5561 end
56- return {}
5762 end ,
5863
5964 constructor = function (tbl )
@@ -74,9 +79,13 @@ _quarto.ast.add_handler({
7479 end ,
7580
7681 inner_content = function (tbl )
77- return {
78- content = tbl .node .content ,
79- }
82+ if is_visible (tbl ) then
83+ return {
84+ content = tbl .node .content ,
85+ }
86+ else
87+ return {}
88+ end
8089 end ,
8190
8291 set_inner_content = function (tbl , content )
0 commit comments