Skip to content

Commit 21c3538

Browse files
authored
Merge pull request #13056 from quarto-dev/backport/crossref-markodwn-table-caption
backport for floatref fix on Captioned Markdown Table in Div syntax
2 parents 11f23b0 + 0e732ee commit 21c3538

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

news/changelog-1.7.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## In this release
44

5+
- ([#13051](https://github.com/quarto-dev/quarto-cli/issues/13051)): Fixed support for captioned Markdown table inside Div syntax for crossref. This is special handling, but this could be output by function like `knitr::kable()` with old option support.
6+
57
## In previous releases
68

79
- ([#6607](https://github.com/quarto-dev/quarto-cli/issues/6607)): Add missing beamer template update for beamer theme options: `colorthemeoptions`, `fontthemeoptions`, `innerthemeoptions` and `outerthemeoptions`.

src/resources/filters/quarto-pre/parsefiguredivs.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ function parse_floatreftargets()
267267
if table.caption.long and next(table.caption.long) then
268268
found_caption = true
269269
caption = table.caption.long[1] -- what if there's more than one entry here?
270+
-- table caption should be removed from the table as we'll handle it
271+
table.caption = pandoc.Caption{}
270272
return table
271273
end
272274
end
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: Crossref Div with Markdown captioned table do not duplicate caption
3+
format: html
4+
keep-tex: true
5+
keep-typ: true
6+
_quarto:
7+
tests:
8+
html:
9+
ensureHtmlElements:
10+
-
11+
- 'div#tbl-1.quarto-float figure.quarto-float.quarto-float-tbl table'
12+
- 'div#tbl-2.quarto-float figure.quarto-float.quarto-float-tbl table'
13+
- 'a[href="#tbl-1"].quarto-xref'
14+
- 'a[href="#tbl-2"].quarto-xref'
15+
-
16+
- 'div#tbl-1.quarto-float table caption'
17+
- 'div#tbl-2.quarto-float table caption'
18+
revealjs:
19+
ensureHtmlElements:
20+
-
21+
- 'div#tbl-1.quarto-float figure.quarto-float.quarto-float-tbl table'
22+
- 'div#tbl-2.quarto-float figure.quarto-float.quarto-float-tbl table'
23+
- 'a[href="#/tbl-1"].quarto-xref'
24+
- 'a[href="#/tbl-2"].quarto-xref'
25+
-
26+
- 'div#tbl-1.quarto-float table caption'
27+
- 'div#tbl-2.quarto-float table caption'
28+
docx:
29+
ensureDocxXpath:
30+
-
31+
- "//w:tbl//w:p//w:r//w:t[contains(text(), \"Table\u00a01\")]"
32+
- "//w:tbl//w:p//w:r//w:t[contains(text(), \"Table\u00a02\")]"
33+
- "//w:hyperlink[@w:anchor='tbl-1']"
34+
- "//w:hyperlink[@w:anchor='tbl-2']"
35+
-
36+
- "//w:tbl//w:tbl//w:tblCaption[contains(@w:val, 'caption for the table 1')]"
37+
- "//w:tbl//w:tbl//w:tblCaption[contains(@w:val, 'caption for the table 2')]"
38+
---
39+
40+
Pandoc's support Caption on Markdown table through a specific syntax: https://pandoc.org/MANUAL.html#extension-table_captions
41+
42+
This test ensure we do catch the caption and do not duplicate
43+
44+
## Using `:` syntax
45+
46+
::: {#tbl-1}
47+
48+
| Default | Left | Right | Center |
49+
|---------|:-----|------:|:------:|
50+
| 12 | 12 | 12 | 12 |
51+
| 123 | 123 | 123 | 123 |
52+
| 1 | 1 | 1 | 1 |
53+
54+
: This is the caption for the table 1
55+
56+
:::
57+
58+
See @tbl-1
59+
60+
## Using `Table:` syntax
61+
62+
::: {#tbl-2}
63+
64+
| Default | Left | Right | Center |
65+
|---------|:-----|------:|:------:|
66+
| 12 | 12 | 12 | 12 |
67+
| 123 | 123 | 123 | 123 |
68+
| 1 | 1 | 1 | 1 |
69+
70+
Table: This is the caption for the table 2
71+
72+
:::
73+
74+
See @tbl-2

0 commit comments

Comments
 (0)