Skip to content

Commit 6202430

Browse files
authored
Merge pull request #9841 from quarto-dev/bugfix/9832
ff-matrix: Callout features
2 parents 9c371c6 + b87fb1d commit 6202430

File tree

10 files changed

+170
-3
lines changed

10 files changed

+170
-3
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: Callout with minimal appearance
3+
format:
4+
html:
5+
quality: 1
6+
---
7+
8+
::: {.callout-note appearance="minimal"}
9+
10+
## Title
11+
12+
{{< lipsum 1 >}}
13+
14+
:::
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: Callout with simple appearance
3+
format:
4+
html:
5+
quality: 1
6+
---
7+
8+
::: {.callout-note appearance="simple"}
9+
10+
## Title
11+
12+
{{< lipsum 1 >}}
13+
14+
:::
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: Callouts
3+
format:
4+
html:
5+
quality: 2
6+
_quarto:
7+
tests:
8+
html:
9+
ensureHtmlElements:
10+
-
11+
- "div.callout-header.collapsed ~ div#callout-1.collapse"
12+
- "div.callout-header:not(.collapsed) ~ div#callout-2.collapse.show"
13+
---
14+
15+
::: {.callout-note collapse="true"}
16+
17+
## A small note
18+
19+
You should note that this is a note.
20+
21+
:::
22+
23+
::: {.callout-note collapse="false"}
24+
25+
## A small note
26+
27+
You should note that this is a note.
28+
29+
:::

dev-docs/feature-format-matrix/qmd-files/callout/document.qmd

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
title: Callouts
33
format:
4-
docusaurus-md:
5-
quality: 1
64
html:
75
quality: 2
6+
docusaurus-md:
7+
quality: 1
88
dashboard:
99
quality: 0
1010
comment: "Bug: Callout icons show on a separate line from the title."
@@ -52,4 +52,35 @@ You should note that this is a note.
5252

5353
A callout does not need a title.
5454

55-
:::
55+
:::
56+
57+
::: {.callout-note}
58+
59+
## A callout does not need content
60+
61+
:::
62+
63+
::: {.callout-note}
64+
65+
:::
66+
67+
::: {.callout-note collapse="true" appearance="minimal"}
68+
69+
## A small note
70+
71+
You should note that this is a note.
72+
73+
:::
74+
75+
::: {.callout}
76+
77+
:::
78+
79+
::: {.callout}
80+
81+
## Title
82+
83+
Content
84+
85+
:::
86+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Callout with no content
3+
format:
4+
html:
5+
quality: 1
6+
---
7+
8+
::: {.callout-note}
9+
10+
## Title
11+
12+
:::
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: Callout with no icon
3+
format:
4+
html:
5+
quality: 0
6+
comment: Title is a offset a little too far down
7+
---
8+
9+
::: {.callout-note icon="false"}
10+
11+
## Title
12+
13+
{{< lipsum 1 >}}
14+
15+
:::
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Callout with no title
3+
format:
4+
html:
5+
quality: 1
6+
---
7+
8+
::: {.callout-note}
9+
10+
{{< lipsum 1 >}}
11+
12+
:::
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Callout with no type
3+
format:
4+
html:
5+
quality: 2
6+
_quarto:
7+
tests:
8+
html:
9+
ensureHtmlElements:
10+
-
11+
- "div.callout.callout-none"
12+
- "div.callout.callout-style-simple"
13+
- "div.callout.no-icon"
14+
---
15+
16+
::: {.callout}
17+
18+
## Title
19+
20+
{{< lipsum 1 >}}
21+
22+
:::

src/resources/filters/modules/callouts.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ local function calloutDiv(node)
194194
-- the first heading is the title
195195
local div = pandoc.Div({})
196196
local c = quarto.utils.as_blocks(node.content)
197+
local has_content = #c > 0
197198
if pandoc.utils.type(c) == "Blocks" then
198199
div.content:extend(c)
199200
else
@@ -254,6 +255,10 @@ local function calloutDiv(node)
254255
local imgPlaceholder = pandoc.Plain({pandoc.RawInline("html", "<i class='callout-icon" .. noicon .. "'></i>")});
255256
local imgDiv = pandoc.Div({imgPlaceholder}, pandoc.Attr("", {"callout-icon-container"}));
256257

258+
if not has_content then
259+
calloutDiv.attr.classes:insert("callout-empty-content")
260+
end
261+
257262
-- show a titled callout
258263
if title ~= nil and (pandoc.utils.type(title) == "string" or next(title) ~= nil) then
259264

@@ -277,6 +282,7 @@ local function calloutDiv(node)
277282
local expandedAttrVal = "true"
278283
if collapse == "true" or collapse == true then
279284
expandedAttrVal = "false"
285+
headerDiv.attr.classes:insert("collapsed")
280286
end
281287

282288
-- create the collapse button

src/resources/formats/html/bootstrap/_bootstrap-rules.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,6 +1382,8 @@ kbd,
13821382
.callout.callout-style-simple .callout-body {
13831383
font-size: 0.9rem;
13841384
font-weight: 400;
1385+
margin-bottom: -0.4em;
1386+
margin-top: 0.5em;
13851387
}
13861388

13871389
.callout.callout-style-default .callout-body {
@@ -1398,6 +1400,15 @@ kbd,
13981400
margin-bottom: -0.2em;
13991401
}
14001402

1403+
.callout.callout-empty-content > .callout-header {
1404+
margin-bottom: 0em;
1405+
border-bottom-right-radius: add($border-radius, -1px);
1406+
}
1407+
1408+
.callout > .callout-header.collapsed {
1409+
border-bottom-right-radius: add($border-radius, -1px);
1410+
}
1411+
14011412
.callout.callout-style-simple > div.callout-header {
14021413
border-bottom: none;
14031414
font-size: 0.9rem;
@@ -1412,6 +1423,7 @@ kbd,
14121423
font-size: 0.9rem;
14131424
padding-left: 0.5em;
14141425
padding-right: 0.5em;
1426+
border-top-right-radius: add($border-radius, -1px);
14151427
}
14161428

14171429
.callout.callout-style-default .callout-body {

0 commit comments

Comments
 (0)