quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.96k stars 326 forks source link

mini-epic: AST uniformization across engines for floats #7062

Open cscheid opened 1 year ago

cscheid commented 1 year ago

All float (Figures, Tables, etc) emitted before Pandoc should emit the same markdown AST.

Let's start with writing tests the generate the documents so we can inspect them.

Issues that are blocked because of this:

Current status

Test documents are in tests/docs/smoke-all/issues/7062-ast-uniformization/*.qmd.

TODO

Simple layouts

Currently, "simple layouts" (single figure, caption and label) are (by inspection) compatible with each other. Jupyter and Knitr both emit images as an "image-style" float:

![Caption here](./image-here.jpg){#fig-label attributes}

OJS, mermaid, and dot all emit div-style floats:

::: {#fig-label attributes}

FIGURE_CONTENT_HERE

Caption here

:::

The exact nature of the content isn't important. It is not perfectly equivalent across formats, but it doesn't have to be, since our FloatRefTarget node works well with this structure.

cscheid commented 1 year ago

Tracking this in the feature/7062 branch.

cscheid commented 1 year ago

Currently, the knitr output for this .qmd

---
title: "Layout test"
keep-md: true
---

```{r}
#| label: fig-charts
#| fig-cap: "Charts"
#| layout: "[1, 1]"

plot(cars)
plot(pressure)

is

::: {.cell layout="[1, 1]"}

plot(cars)
plot(pressure)

::: {.cell-output-display} Charts{#fig-charts-1 width=672} :::

::: {.cell-output-display} Charts{#fig-charts-2 width=672} ::: :::


That confuses quarto. I think the output should be this:

::: {#fig-charts .cell layout="[1, 1]" fig-cap="Charts"}

plot(cars)
plot(pressure)

::: {.cell-output-display} {#fig-charts-1 width=672} :::

::: {.cell-output-display} {#fig-charts-2 width=672} :::

:::



Concretely:

- no caption in the inner figures (because single string in `fig-cap` denotes overall figure caption)
- figure label in outer figures (because otherwise we don't have a label to do crossref work)
- `fig-cap="Charts"` in the cell, so that we have an overall caption
cscheid commented 3 months ago

This is breaking some of @andrewpbray's extensions; I'm sure that's true for other folks as well. We're short on 1.6 time but I think we need to do something about this soon.