Skip to content

Commit

Permalink
Merge pull request #10876 from quarto-dev/bugfix/10821
Browse files Browse the repository at this point in the history
Be more conservative in stripping `echo: fenced` from fenced output
  • Loading branch information
cscheid committed Sep 25, 2024
2 parents d30cb38 + 8d1cbfb commit d9c92ef
Show file tree
Hide file tree
Showing 5 changed files with 40 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 @@ -88,3 +88,4 @@ All changes included in 1.6:
- ([#10552](https://github.com/quarto-dev/quarto-cli/issues/10552)): Add `contents` shortcode.
- ([#10581](https://github.com/quarto-dev/quarto-cli/issues/10581)): Add `.landscape` div processing to `typst`, `docx` and `pdf` formats to support pages in landscape orientation.
- ([#10591](https://github.com/quarto-dev/quarto-cli/issues/10591)): Make fenced div syntax slightly more robust by removing spaces around the `=` sign ahead of Pandoc's reader.
- ([#10821](https://github.com/quarto-dev/quarto-cli/issues/10821)): Be more conservative in stripping `echo: fenced` from fenced output.
2 changes: 1 addition & 1 deletion src/core/jupyter/jupyter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ async function mdFromCodeCell(
let source = ld.cloneDeep(cell.source);
if (fenced) {
const optionsSource = cell.optionsSource.filter((line) =>
line.search(/echo:\s+fenced/) === -1
line.search(/\|\s+echo:\s+fenced\s*$/) === -1
);
if (optionsSource.length > 0) {
source = trimEmptyLines(source, "trailing");
Expand Down
2 changes: 1 addition & 1 deletion src/resources/rmd/hooks.R
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ knitr_hooks <- function(format, resourceDir, handledLanguages) {
lang <- NULL
yamlCode <- lastYamlCode
if (!is.null(yamlCode)) {
yamlCode <- Filter(function(line) !grepl("echo:\\s+fenced", line), yamlCode)
yamlCode <- Filter(function(line) !grepl("\\|\\s+echo:\\s+fenced\\s*$", line), yamlCode)
yamlCode <- paste(yamlCode, collapse = "\n")
if (!nzchar(yamlCode)) {
x <- trimws(x, "left")
Expand Down
19 changes: 19 additions & 0 deletions tests/docs/smoke-all/2024/09/24/issue-10821-b.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: issue-10821
format: html
_quarto:
tests:
html:
ensureFileRegexMatches:
- ['<span class="in">#\| fig-cap: ''This figure will have ''''echo: fenced'''' in its caption.''</span>']
- []
# - ['fig-cap']
---

```{python}
#| echo: fenced
#| label: fig-1
#| fig-cap: "This figure will have 'echo: fenced' in its caption."
import matplotlib.pyplot as plt
plt.plot([1,2,3])
```
18 changes: 18 additions & 0 deletions tests/docs/smoke-all/2024/09/24/issue-10821.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: issue-10821
format: html
_quarto:
tests:
html:
ensureFileRegexMatches:
- ['<span class="in">#\| fig-cap: "This figure will have ''echo: fenced'' in its caption."</span>']
- []
---

```{r}
#| echo: fenced
#| whatever: "echo: fenced"
#| fig-cap: "This figure will have 'echo: fenced' in its caption."
#| label: fig-1
plot(1:100)
```

0 comments on commit d9c92ef

Please sign in to comment.