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
10 changes: 8 additions & 2 deletions src/resources/filters/layout/asciidoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,15 @@ end, function(layout)
local content_str = pandoc.write(_quarto.ast.walk(pandoc.Pandoc(panel_content), render_extended_nodes()) or {}, "asciidoc")
local figure_str = ". " .. caption_str .. "[#" .. layout.identifier .. "]\n" .. content_str

if layout.preamble then
local pt = pandoc.utils.type(layout.preamble)
if pt == "Blocks" then
layout.preamble:insert(pandoc.RawBlock("asciidoc", figure_str))
return layout.preamble
elseif pt == "Block" then
return pandoc.Blocks({ layout.preamble, pandoc.RawBlock("asciidoc", figure_str) })
else
elseif pt == "nil" then
return pandoc.RawBlock("asciidoc", figure_str)
else
internal_error()
end
end)
10 changes: 8 additions & 2 deletions src/resources/filters/layout/jats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,15 @@ end, function(layout)
decorate_caption_with_crossref(layout.float)
local result = pandoc.Figure(panel_content, {layout.float.caption_long}, attr)

if layout.preamble then
local pt = pandoc.utils.type(layout.preamble)
if pt == "Blocks" then
layout.preamble:insert(result)
return layout.preamble
elseif pt == "Block" then
return pandoc.Blocks({ layout.preamble, result })
else
elseif pt == "nil" then
return result
else
internal_error()
end
end)
3 changes: 0 additions & 3 deletions src/resources/filters/quarto-pre/parsefiguredivs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,9 @@ function parse_floats()
end
end

-- luacov: disable
if caption == nil then
internal_error()
return nil
end
-- luacov: enable

local identifier = div.identifier
local attr = pandoc.Attr(identifier, div.classes, div.attributes)
Expand Down
66 changes: 66 additions & 0 deletions tests/docs/smoke-all/2023/09/18/6871-adoc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---

title: Knitr Table Test
format: asciidoc
keep-md: true
\_quarto:
tests:
asciidoc:
ensureFileRegexMatches: # The checks here are looser than I'd like, because checking for asciidoc # nested structures in line-by-line regexes seems impossible, but this # is the only smoke-all test we can run in asciidoc.. # # TODO this is a problem. - - "\\[\\[tbl-cars\\]\\]" - "\\[\\[tbl-pressure\\]\\]" - "\\[#tbl-tables\\]" # TODO understand the difference between [[foo]] and [#foo]. From my reading of the asciidoc docs it seems ok but we should double-check. - "\\. Tables" - "\\. Cars" - "\\. Pressure" - []

---

::: {#tbl-tables .cell layout-ncol="2" tbl-cap='Tables'}

```{.r .cell-code}
library(knitr)
```

::: {.cell-output .cell-output-stderr}

```
Warning: le package 'knitr' a été compilé avec la version R 4.2.3
```

:::

```{.r .cell-code}
kable(head(cars), caption = "Cars {#tbl-cars}")
```

::: {.cell-output-display}

Table: Cars {#tbl-cars}

| speed | dist |
| ----: | ---: |
| 4 | 2 |
| 4 | 10 |
| 7 | 4 |
| 7 | 22 |
| 8 | 16 |
| 9 | 10 |

:::

```{.r .cell-code}
kable(head(pressure), caption = "Pressure {#tbl-pressure}")
```

::: {.cell-output-display}

Table: Pressure {#tbl-pressure}

| temperature | pressure |
| ----------: | -------: |
| 0 | 0.0002 |
| 20 | 0.0012 |
| 40 | 0.0060 |
| 60 | 0.0300 |
| 80 | 0.0900 |
| 100 | 0.2700 |

:::
:::

See @tbl-cars for more information.
72 changes: 72 additions & 0 deletions tests/docs/smoke-all/2023/09/18/6871.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: Knitr Table Test
format: jats
keep-md: true
_quarto:
tests:
jats:
ensureJatsXpath:
- - '//fig//fig[@id="tbl-cars"]//table'
- '//fig//fig[@id="tbl-cars"]//caption'
- '//fig//fig[@id="tbl-pressure"]//table'
- '//fig//fig[@id="tbl-pressure"]//caption'
- '//fig[@id="tbl-tables"]/caption'
- []
---

::: {#tbl-tables .cell layout-ncol="2" tbl-cap='Tables'}

```{.r .cell-code}
library(knitr)
```

::: {.cell-output .cell-output-stderr}

```
Warning: le package 'knitr' a été compilé avec la version R 4.2.3
```

:::

```{.r .cell-code}
kable(head(cars), caption = "Cars {#tbl-cars}")
```

::: {.cell-output-display}

Table: Cars {#tbl-cars}

| speed | dist |
| ----: | ---: |
| 4 | 2 |
| 4 | 10 |
| 7 | 4 |
| 7 | 22 |
| 8 | 16 |
| 9 | 10 |

:::

```{.r .cell-code}
kable(head(pressure), caption = "Pressure {#tbl-pressure}")
```

::: {.cell-output-display}

Table: Pressure {#tbl-pressure}

| temperature | pressure |
| ----------: | -------: |
| 0 | 0.0002 |
| 20 | 0.0012 |
| 40 | 0.0060 |
| 60 | 0.0300 |
| 80 | 0.0900 |
| 100 | 0.2700 |

:::
:::

See @tbl-cars for more information.

</details>
Loading