Skip to content

Commit 4a7a934

Browse files
authored
Merge pull request #11347 from quarto-dev/fix/table-cap-bottom-odd-even
2 parents 61b87ed + b2aa367 commit 4a7a934

File tree

12 files changed

+204
-12
lines changed

12 files changed

+204
-12
lines changed

src/resources/filters/quarto-post/html.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ function render_html_fixups()
4242
-- this requires bootstrap CSS
4343
if quarto.doc.crossref.cap_location(tbl) == "top" then
4444
tbl.classes:insert("caption-top")
45-
return tbl
4645
end
46+
47+
return tbl
4748
end,
4849
Figure = function(fig)
4950
if #fig.content ~= 1 then
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: Markdown Tables
3+
tbl-cap-location: bottom
4+
---
5+
6+
They should be styled by Quarto
7+
8+
## labelled {#labelled}
9+
10+
| Col1 | Col2 | Col3 |
11+
|------|------|------|
12+
| A | B | C |
13+
| E | F | G |
14+
| A | G | G |
15+
16+
: My Caption {#tbl-letters}
17+
18+
See @tbl-letters.
19+
20+
## non-labelled table {#non-labelled}
21+
22+
| Col1 | Col2 | Col3 |
23+
|------|------|------|
24+
| A | B | C |
25+
| E | F | G |
26+
27+
: A non-labelled table with a caption
28+
29+
## Computational table {#computation}
30+
31+
<!-- This is equivalent to intermediate markdown from a `knitr::kable()` output with `echo: false` -->
32+
33+
:::: {.cell}
34+
::: {.cell-output-display}
35+
36+
Table: A caption
37+
38+
| Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
39+
|-------------:|------------:|-------------:|------------:|:--------|
40+
| 5.1 | 3.5 | 1.4 | 0.2 | setosa |
41+
| 4.9 | 3.0 | 1.4 | 0.2 | setosa |
42+
| 4.7 | 3.2 | 1.3 | 0.2 | setosa |
43+
| 4.6 | 3.1 | 1.5 | 0.2 | setosa |
44+
| 5.0 | 3.6 | 1.4 | 0.2 | setosa |
45+
| 5.4 | 3.9 | 1.7 | 0.4 | setosa |
46+
:::
47+
::::

tests/docs/playwright/html/markdown-tables.qmd renamed to tests/docs/playwright/html/tables/markdown-tables.qmd

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
---
22
title: Markdown Tables
3+
tbl-cap-location: bottom
34
---
45

56
They should be styled by Quarto
67

8+
## labelled {#labelled}
9+
710
| Col1 | Col2 | Col3 |
811
|------|------|------|
912
| A | B | C |
@@ -14,12 +17,24 @@ They should be styled by Quarto
1417

1518
See @tbl-letters.
1619

17-
## Computational table
20+
## non-labelled table {#non-labelled}
21+
22+
| Col1 | Col2 | Col3 |
23+
|------|------|------|
24+
| A | B | C |
25+
| E | F | G |
26+
27+
: A non-labelled table with a caption
28+
29+
## Computational table {#computation}
1830

1931
<!-- This is equivalent to intermediate markdown from a `knitr::kable()` output with `echo: false` -->
2032

21-
:::: cell
22-
::: cell-output-display
33+
:::: {.cell}
34+
::: {.cell-output-display}
35+
36+
Table: A caption
37+
2338
| Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
2439
|-------------:|------------:|-------------:|------------:|:--------|
2540
| 5.1 | 3.5 | 1.4 | 0.2 | setosa |
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
title: Table Appearance
3+
tbl-cap-location: bottom
4+
format: html
5+
_quarto:
6+
tests:
7+
html:
8+
ensureHtmlElements:
9+
- ['table tbody tr.odd', 'table tbody tr.even']
10+
- ['table tbody tr:not(.odd):not(.even)'] # All table should have .odd .even class for styling
11+
---
12+
13+
### Md table (w/caption) {#captioned}
14+
15+
A short sentence that makes a paragraph.
16+
17+
| Default | Left | Right | Center |
18+
|---------|:-----|------:|:------:|
19+
| 12 | 12 | 12 | 12 |
20+
| 123 | 123 | 123 | 123 |
21+
| 1 | 1 | 1 | 1 |
22+
23+
: Demonstration of pipe table syntax
24+
25+
### fancy table
26+
27+
A short sentence that makes a paragraph.
28+
29+
| fruit | price |
30+
|--------|--------|
31+
| apple | 2.05 |
32+
| pear | 1.37 |
33+
| orange | 3.09 |
34+
35+
: Fruit prices {.striped .hover}
36+
37+
38+
### xref table
39+
40+
A short sentence that makes a paragraph.
41+
42+
| Col1 | Col2 | Col3 |
43+
|------|------|------|
44+
| A | B | C |
45+
| E | F | G |
46+
| A | G | G |
47+
48+
: My Caption {#tbl-letters}
49+
50+
See @tbl-letters.
51+
52+
### subtables
53+
54+
A short sentence that makes a paragraph.
55+
56+
::: {#tbl-panel layout-ncol=2}
57+
| Col1 | Col2 | Col3 |
58+
|------|------|------|
59+
| A | B | C |
60+
| E | F | G |
61+
| A | G | G |
62+
63+
: First Table {#tbl-first}
64+
65+
| Col1 | Col2 | Col3 |
66+
|------|------|------|
67+
| A | B | C |
68+
| E | F | G |
69+
| A | G | G |
70+
71+
: Second Table {#tbl-second}
72+
73+
Main Caption
74+
:::
75+
76+
See @tbl-panel for details, especially @tbl-second.
77+
78+
### HTML Table
79+
80+
```{=html}
81+
<table>
82+
<caption>As described in the section above, Quarto tables are great.</caption>
83+
<thead>
84+
<tr>
85+
<th>Header 1</th>
86+
<th>Header 2</th>
87+
</tr>
88+
</thead>
89+
<tbody>
90+
<tr>
91+
<td>First Column</td>
92+
<td>Second Column</td>
93+
</tr>
94+
</tbody>
95+
</table>
96+
```

tests/docs/smoke-all/table/appearance.qmd

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
---
22
title: Table Appearance
33
format: html
4+
_quarto:
5+
tests:
6+
html:
7+
ensureHtmlElements:
8+
- ['table tbody tr.odd', 'table tbody tr.even']
9+
- ['table tbody tr:not(.odd):not(.even)'] # All table should have .odd .even class for styling
410
---
511

612
### With header
@@ -22,7 +28,7 @@ left 1 right 1
2228
left 2 right 2
2329
----------- ------------
2430

25-
### Md table (w/caption)
31+
### Md table (w/caption) {#captioned}
2632

2733
A short sentence that makes a paragraph.
2834

@@ -85,4 +91,24 @@ A short sentence that makes a paragraph.
8591
Main Caption
8692
:::
8793

88-
See @tbl-panel for details, especially @tbl-second.
94+
See @tbl-panel for details, especially @tbl-second.
95+
96+
### HTML Table
97+
98+
```{=html}
99+
<table>
100+
<caption>As described in the section above, Quarto tables are great.</caption>
101+
<thead>
102+
<tr>
103+
<th>Header 1</th>
104+
<th>Header 2</th>
105+
</tr>
106+
</thead>
107+
<tbody>
108+
<tr>
109+
<td>First Column</td>
110+
<td>Second Column</td>
111+
</tr>
112+
</tbody>
113+
</table>
114+
```
4 Bytes
Loading
-7.06 KB
Loading
12.9 KB
Loading
3.38 KB
Loading
4.69 KB
Loading

0 commit comments

Comments
 (0)