-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11347 from quarto-dev/fix/table-cap-bottom-odd-even
- Loading branch information
Showing
12 changed files
with
204 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
tests/docs/playwright/html/tables/markdown-tables-cap-bottom.qmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
title: Markdown Tables | ||
tbl-cap-location: bottom | ||
--- | ||
|
||
They should be styled by Quarto | ||
|
||
## labelled {#labelled} | ||
|
||
| Col1 | Col2 | Col3 | | ||
|------|------|------| | ||
| A | B | C | | ||
| E | F | G | | ||
| A | G | G | | ||
|
||
: My Caption {#tbl-letters} | ||
|
||
See @tbl-letters. | ||
|
||
## non-labelled table {#non-labelled} | ||
|
||
| Col1 | Col2 | Col3 | | ||
|------|------|------| | ||
| A | B | C | | ||
| E | F | G | | ||
|
||
: A non-labelled table with a caption | ||
|
||
## Computational table {#computation} | ||
|
||
<!-- This is equivalent to intermediate markdown from a `knitr::kable()` output with `echo: false` --> | ||
|
||
:::: {.cell} | ||
::: {.cell-output-display} | ||
|
||
Table: A caption | ||
|
||
| Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species | | ||
|-------------:|------------:|-------------:|------------:|:--------| | ||
| 5.1 | 3.5 | 1.4 | 0.2 | setosa | | ||
| 4.9 | 3.0 | 1.4 | 0.2 | setosa | | ||
| 4.7 | 3.2 | 1.3 | 0.2 | setosa | | ||
| 4.6 | 3.1 | 1.5 | 0.2 | setosa | | ||
| 5.0 | 3.6 | 1.4 | 0.2 | setosa | | ||
| 5.4 | 3.9 | 1.7 | 0.4 | setosa | | ||
::: | ||
:::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
--- | ||
title: Table Appearance | ||
tbl-cap-location: bottom | ||
format: html | ||
_quarto: | ||
tests: | ||
html: | ||
ensureHtmlElements: | ||
- ['table tbody tr.odd', 'table tbody tr.even'] | ||
- ['table tbody tr:not(.odd):not(.even)'] # All table should have .odd .even class for styling | ||
--- | ||
|
||
### Md table (w/caption) {#captioned} | ||
|
||
A short sentence that makes a paragraph. | ||
|
||
| Default | Left | Right | Center | | ||
|---------|:-----|------:|:------:| | ||
| 12 | 12 | 12 | 12 | | ||
| 123 | 123 | 123 | 123 | | ||
| 1 | 1 | 1 | 1 | | ||
|
||
: Demonstration of pipe table syntax | ||
|
||
### fancy table | ||
|
||
A short sentence that makes a paragraph. | ||
|
||
| fruit | price | | ||
|--------|--------| | ||
| apple | 2.05 | | ||
| pear | 1.37 | | ||
| orange | 3.09 | | ||
|
||
: Fruit prices {.striped .hover} | ||
|
||
|
||
### xref table | ||
|
||
A short sentence that makes a paragraph. | ||
|
||
| Col1 | Col2 | Col3 | | ||
|------|------|------| | ||
| A | B | C | | ||
| E | F | G | | ||
| A | G | G | | ||
|
||
: My Caption {#tbl-letters} | ||
|
||
See @tbl-letters. | ||
|
||
### subtables | ||
|
||
A short sentence that makes a paragraph. | ||
|
||
::: {#tbl-panel layout-ncol=2} | ||
| Col1 | Col2 | Col3 | | ||
|------|------|------| | ||
| A | B | C | | ||
| E | F | G | | ||
| A | G | G | | ||
|
||
: First Table {#tbl-first} | ||
|
||
| Col1 | Col2 | Col3 | | ||
|------|------|------| | ||
| A | B | C | | ||
| E | F | G | | ||
| A | G | G | | ||
|
||
: Second Table {#tbl-second} | ||
|
||
Main Caption | ||
::: | ||
|
||
See @tbl-panel for details, especially @tbl-second. | ||
|
||
### HTML Table | ||
|
||
```{=html} | ||
<table> | ||
<caption>As described in the section above, Quarto tables are great.</caption> | ||
<thead> | ||
<tr> | ||
<th>Header 1</th> | ||
<th>Header 2</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>First Column</td> | ||
<td>Second Column</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+4 Bytes
(100%)
...eenshots__/html-tables.spec.ts/win32/Markdown-tables-are-styled-correctly-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-7.06 KB
(40%)
...eenshots__/html-tables.spec.ts/win32/Markdown-tables-are-styled-correctly-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.9 KB
...eenshots__/html-tables.spec.ts/win32/Markdown-tables-are-styled-correctly-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.38 KB
...eenshots__/html-tables.spec.ts/win32/Markdown-tables-are-styled-correctly-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.69 KB
...eenshots__/html-tables.spec.ts/win32/Markdown-tables-are-styled-correctly-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.9 KB
...eenshots__/html-tables.spec.ts/win32/Markdown-tables-are-styled-correctly-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('Markdown tables are styled correctly', async ({ page }) => { | ||
await page.goto('html/markdown-tables.html'); | ||
await expect(page.getByRole('figure', { name: 'Table 1: My Caption' }).locator('table')).toHaveScreenshot() | ||
await expect(page.locator('a.quarto-xref[href="#tbl-letters"]')).toContainText('Table 1'); | ||
async function testTables(page, path: string) { | ||
await page.goto(`html/tables/${path}`); | ||
await expect(page.locator('#labelled table')).toHaveScreenshot(); | ||
await expect(page.locator('a.quarto-xref[href="#tbl-letters"]')).toContainText('Table 1'); | ||
await expect(page.locator('#non-labelled table')).toHaveScreenshot(); | ||
await expect(page.locator('#computation table')).toHaveScreenshot(); | ||
} | ||
|
||
await expect(page.locator('#computational-table table')).toHaveScreenshot() | ||
test('Markdown tables are styled correctly', async ({ page }) => { | ||
// Test with default caption position | ||
await testTables(page, 'markdown-tables.html'); | ||
|
||
}); | ||
// Test with bottom caption | ||
await testTables(page, 'markdown-tables-cap-bottom.html'); | ||
}); |