Skip to content

Commit

Permalink
Merge pull request #11011 from quarto-dev/bugfix/8179
Browse files Browse the repository at this point in the history
layout - do not merge code blocks with different classes
  • Loading branch information
cscheid authored Oct 8, 2024
2 parents 95a1626 + ab8b264 commit 07f55ab
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/changelog-1.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All changes included in 1.6:

## Lua Filters and extensions

- ([#8179](https://github.com/quarto-dev/quarto-cli/issues/8179)): When merging code cells for complex layouts, do not merge cells with different languages.
- ([#10004](https://github.com/quarto-dev/quarto-cli/issues/10004)): Resolve callout titles, theorem names, and `code-summary` content through `quarto_ast_pipeline()` and `process_shortcodes()`.
- ([#10196](https://github.com/quarto-dev/quarto-cli/issues/10196)): Protect against nil values in `float.caption_long`.
- ([#10328](https://github.com/quarto-dev/quarto-cli/issues/10328)): Interpret subcells as subfloats when subcap count matches subcell count.
Expand Down
12 changes: 10 additions & 2 deletions src/resources/filters/layout/layout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,16 @@ function partition_cells(float)
end

local function handle_preamble_codeblock(block)
if block.t == "CodeBlock" and #preamble > 0 and preamble[#preamble].t == "CodeBlock" then
preamble[#preamble].text = preamble[#preamble].text .. "\n" .. block.text
if #preamble == 0 then
preamble:insert(block)
return
end
local last = preamble[#preamble]
if block.t == "CodeBlock" and
last.t == "CodeBlock" and
-- https://pandoc.org/lua-filters.html#pandoc.list:__eq
last.classes == block.classes then
last.text = last.text .. "\n" .. block.text
else
preamble:insert(block)
end
Expand Down
76 changes: 76 additions & 0 deletions tests/docs/smoke-all/2024/10/08/issue-8179.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: "Block layout"
format: html
engine: knitr
keep-md: true
_quarto:
tests:
html:
ensureHtmlElements:
-
- "pre.r"
- "pre.python"
- []
---




# Code chunk block layout

:::: {layout="[48,-4,48]"}

::: {}

### R



::: {.cell}

```{.r .cell-code}
sqrt(2)
```

::: {.cell-output .cell-output-stdout}

```
[1] 1.414214
```


:::
:::



:::

::: {}

### Python



::: {.cell}

```{.python .cell-code}
import math
math.sqrt(2)
```

::: {.cell-output .cell-output-stdout}

```
1.4142135623730951
```


:::
:::



:::

::::

0 comments on commit 07f55ab

Please sign in to comment.