From 9fa72539b13a67baf397d29c1e5cc2ff25345aa9 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Tue, 24 Sep 2024 14:26:24 -0700 Subject: [PATCH 1/3] be more conservative in filtering 'echo: fenced' --- src/core/jupyter/jupyter.ts | 2 +- src/resources/rmd/hooks.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/jupyter/jupyter.ts b/src/core/jupyter/jupyter.ts index ee86aaa445..f246c0a4e3 100644 --- a/src/core/jupyter/jupyter.ts +++ b/src/core/jupyter/jupyter.ts @@ -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"); diff --git a/src/resources/rmd/hooks.R b/src/resources/rmd/hooks.R index 6982d47280..530cbd11b3 100644 --- a/src/resources/rmd/hooks.R +++ b/src/resources/rmd/hooks.R @@ -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") From c9ea202f9adaa992fdaff9244fd8d9f03e634195 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Tue, 24 Sep 2024 14:39:37 -0700 Subject: [PATCH 2/3] regression tests --- .../smoke-all/2024/09/24/issue-10821-b.qmd | 19 +++++++++++++++++++ .../docs/smoke-all/2024/09/24/issue-10821.qmd | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/docs/smoke-all/2024/09/24/issue-10821-b.qmd create mode 100644 tests/docs/smoke-all/2024/09/24/issue-10821.qmd diff --git a/tests/docs/smoke-all/2024/09/24/issue-10821-b.qmd b/tests/docs/smoke-all/2024/09/24/issue-10821-b.qmd new file mode 100644 index 0000000000..434e98a14c --- /dev/null +++ b/tests/docs/smoke-all/2024/09/24/issue-10821-b.qmd @@ -0,0 +1,19 @@ +--- +title: issue-10821 +format: html +_quarto: + tests: + html: + ensureFileRegexMatches: + - ['#\| fig-cap: ''This figure will have ''''echo: fenced'''' in its caption.'''] + - [] + # - ['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]) +``` diff --git a/tests/docs/smoke-all/2024/09/24/issue-10821.qmd b/tests/docs/smoke-all/2024/09/24/issue-10821.qmd new file mode 100644 index 0000000000..5fb8830a28 --- /dev/null +++ b/tests/docs/smoke-all/2024/09/24/issue-10821.qmd @@ -0,0 +1,18 @@ +--- +title: issue-10821 +format: html +_quarto: + tests: + html: + ensureFileRegexMatches: + - ['#\| fig-cap: "This figure will have ''echo: fenced'' in its caption."'] + - [] +--- + +```{r} +#| echo: fenced +#| whatever: "echo: fenced" +#| fig-cap: "This figure will have 'echo: fenced' in its caption." +#| label: fig-1 +plot(1:100) +``` From 8d1cbfb1c1eab08198edd27cf34cf3e407139118 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Tue, 24 Sep 2024 14:40:31 -0700 Subject: [PATCH 3/3] changelog --- news/changelog-1.6.md | 1 + 1 file changed, 1 insertion(+) diff --git a/news/changelog-1.6.md b/news/changelog-1.6.md index 031785e216..c7e8ef1743 100644 --- a/news/changelog-1.6.md +++ b/news/changelog-1.6.md @@ -87,3 +87,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.