From 962c77e8a56932567360dd3f17a27b81ea12f501 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 22 Dec 2023 15:50:16 +0100 Subject: [PATCH] Correctly check when format is only a string and add test --- src/core/jupyter/jupyter-fixups.ts | 10 ++++++-- .../09/03/revealjs-title-snipping-jupyter.qmd | 24 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 tests/docs/smoke-all/2024/09/03/revealjs-title-snipping-jupyter.qmd diff --git a/src/core/jupyter/jupyter-fixups.ts b/src/core/jupyter/jupyter-fixups.ts index c7d38b1ed3..222d6c3631 100644 --- a/src/core/jupyter/jupyter-fixups.ts +++ b/src/core/jupyter/jupyter-fixups.ts @@ -164,9 +164,15 @@ export function fixupFrontMatter(nb: JupyterNotebook): JupyterNotebook { } }); - // if we have front matter and a title then we are done const yaml = partitioned ? readYamlFromMarkdown(partitioned.yaml) : undefined; - if (yaml?.title || yaml?.format?.["revealjs"]) { + if ( + // if we have front matter and a title then we are done + yaml?.title || + // if we have front matter and it has revealjs as a format then we are done too + (yaml?.format !== null && + (yaml?.format === "revealjs" || + (typeof yaml?.format === "object" && "revealjs" in yaml?.format))) + ) { return nb; } diff --git a/tests/docs/smoke-all/2024/09/03/revealjs-title-snipping-jupyter.qmd b/tests/docs/smoke-all/2024/09/03/revealjs-title-snipping-jupyter.qmd new file mode 100644 index 0000000000..7a179545fc --- /dev/null +++ b/tests/docs/smoke-all/2024/09/03/revealjs-title-snipping-jupyter.qmd @@ -0,0 +1,24 @@ +--- +format: revealjs +_quarto: + tests: + revealjs: + ensureHtmlElements: + - ['div.slides > section#custom:first-child'] + - [] + ensureFileRegexMatches: + - [] + - [] +--- + +## My Title slide {#custom .center} + +Some content + + +## Python slide + +```{python} +print(2+2) +``` +