Skip to content

Commit

Permalink
Merge pull request #8634 from quarto-dev/bugfix/8614
Browse files Browse the repository at this point in the history
Article Layout - column forwarding
  • Loading branch information
dragonstyle authored Feb 7, 2024
2 parents 3b6fff2 + 4b82db5 commit 56fd935
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
4 changes: 4 additions & 0 deletions news/changelog-1.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ All changes included in 1.5:

- ([#8388](https://github.com/quarto-dev/quarto-cli/issues/8388)): add `QUARTO_PROJECT_ROOT` and `QUARTO_DOCUMENT_PATH` to the environment when invoking execution engines.

## Article Layout

- ([#8614](https://github.com/quarto-dev/quarto-cli/issues/8614)): Don't improperly forward column classes onto grids.

## Other Fixes

- ([#8119](https://github.com/quarto-dev/quarto-cli/issues/8119)): More intelligently detect when ejs templates are modified during development, improving quality of life during preview.
Expand Down
14 changes: 14 additions & 0 deletions src/format/html/format-html-bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,8 @@ const figCapInCalloutMarginProcessor: MarginNodeProcessor = {
},
};

const kPreviewFigColumnForwarding = [".grid"];

const processFigureOutputs = (doc: Document) => {
// For any non-margin figures, we want to actually place the figure itself
// into the column, and leave the caption as is, if possible
Expand All @@ -1478,6 +1480,18 @@ const processFigureOutputs = (doc: Document) => {
// See if this is a code cell with a single figure output
const columnEl = columnNode as Element;

// See if there are any classes which should prohibit forwarding
// the column information
if (
kPreviewFigColumnForwarding.some((sel) => {
return columnEl.querySelector(sel) !== null;
})
) {
// There are matching ignore selectors, just skip
// this column
continue;
}

// If there is a single figure, then forward the column class onto that
const figures = columnEl.querySelectorAll("figure img.figure-img");
if (figures && figures.length === 1) {
Expand Down
49 changes: 49 additions & 0 deletions tests/docs/smoke-all/article-layout/grid.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: Bug 8614
format:
html:
page-layout: article
_quarto:
tests:
html:
ensureHtmlElements:
- [".column-page > div.grid"]
- [".grid.page-columns"]
---


The below two computational chunks are expected to produce a table and a plot side-by-side, by using `::: {.grid}` with `::: {.g-col-6}` underneath `::: {column-page}`.

::::: {.column-page}

::::: {.grid}

::: {.g-col-6}

```{r}
#| label: tbl-iris
"there was a table here...but it was unnecessary for the reprex."
```
:::

::: {.g-col-6}

```{r}
#| label: fig-plot
#| fig-cap: "my caption"
#| fig-cap-location: bottom
#| out-width: "30%"
#| echo: true
data(iris)
hist(iris$Sepal.Length)
```
:::

:::::

:::::

0 comments on commit 56fd935

Please sign in to comment.