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
1 change: 1 addition & 0 deletions news/changelog-1.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ All changes included in 1.5:
- ([#9539](https://github.com/quarto-dev/quarto-cli/issues/9539)): Improve SCSS of title blocks to avoid overwide columns in grid layout.
- Improve accessibility `role` for `aria-expandable` elements by ensuring their role supports the `aria-expanded` attribute.
- ([#3178](https://github.com/quarto-dev/quarto-cli/issues/3178)): TOC now correctly expands when web page has no content to scroll to.
- ([#9734](https://github.com/quarto-dev/quarto-cli/issues/9734)): Fix issue with unlabeled tables and `tbl-cap-location` information.

## PDF Format

Expand Down
8 changes: 6 additions & 2 deletions src/resources/filters/customnodes/floatreftarget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,13 @@ function cap_location(obj)
-- ref-parents
ref = refType(obj.identifier) or refType(obj.attributes["ref-parent"] or "")
end
-- last resort, pretend we're a figure
if ref == nil or crossref.categories.by_ref_type[ref] == nil then
ref = "fig"
if obj.t == "Table" then
ref = "tbl"
else
-- last resort, pretend we're a figure
ref = "fig"
end
end
local qualified_key = ref .. '-cap-location'
local result = (
Expand Down
7 changes: 7 additions & 0 deletions src/resources/filters/quarto-post/html.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ function render_html_fixups()
end

return {
Table = function(tbl)
-- this requires bootstrap CSS
if quarto.doc.crossref.cap_location(tbl) == "top" then
tbl.classes:insert("caption-top")
return tbl
end
end,
Figure = function(fig)
if #fig.content ~= 1 then
return nil
Expand Down
17 changes: 17 additions & 0 deletions tests/docs/smoke-all/2024/05/21/9734-a.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Table caption location
tbl-cap-location: top
format: html
_quarto:
tests:
html:
ensureHtmlElements:
- ["table.caption-top"]
---

| Col1 | Col2 | Col3 |
|------|------|------|
| A | B | C |
| E | F | G |

: A non-labelled table with a caption
18 changes: 18 additions & 0 deletions tests/docs/smoke-all/2024/05/21/9734-b.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: Table caption location
tbl-cap-location: bottom
format: html
_quarto:
tests:
html:
ensureHtmlElements:
- []
- ["table.caption-top"]
---

| Col1 | Col2 | Col3 |
|------|------|------|
| A | B | C |
| E | F | G |

: A non-labelled table with a caption
16 changes: 16 additions & 0 deletions tests/docs/smoke-all/2024/05/21/9734-c.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: Table caption location
format: html
_quarto:
tests:
html:
ensureHtmlElements:
- ["table.caption-top"]
---

| Col1 | Col2 | Col3 |
|------|------|------|
| A | B | C |
| E | F | G |

: A non-labelled table with a caption