From 3d19a720a1153df7791a6f407b30a0a6d83471a0 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 15 Jul 2026 15:00:47 +0200 Subject: [PATCH 1/2] Fix ipynb rendering an empty title header when no title is set (#14693) title-block.md unconditionally emitted a level-1 markdown header for every ipynb render, even without a title, producing a stray "# " line in the notebook's first cell. Every other title template in the codebase (html, pdf/beamer, typst, asciidoc) already guards this with $if(title)$; ipynb was missing it since the template was first added. --- news/changelog-1.10.md | 4 ++++ src/resources/formats/ipynb/templates/title-block.md | 2 +- tests/docs/doc-layout/title-block-no-title.qmd | 1 + tests/smoke/render/render-title-block.test.ts | 10 ++++++++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/docs/doc-layout/title-block-no-title.qmd diff --git a/news/changelog-1.10.md b/news/changelog-1.10.md index d3422010c4..c645725178 100644 --- a/news/changelog-1.10.md +++ b/news/changelog-1.10.md @@ -49,6 +49,10 @@ All changes included in 1.10: - ([#14646](https://github.com/quarto-dev/quarto-cli/issues/14646)): Fix inline code formatting in a dashboard card title being extracted from its original position and appended elsewhere in the header instead of staying inline, the same issue previously fixed for math, emphasis and bold in [#10340](https://github.com/quarto-dev/quarto-cli/issues/10340). +### `ipynb` + +- ([#14693](https://github.com/quarto-dev/quarto-cli/issues/14693)): Fix an empty level-1 heading (`# `) being emitted in the first markdown cell when rendering a document with no `title` to `ipynb`. + ## Projects ### Manuscripts diff --git a/src/resources/formats/ipynb/templates/title-block.md b/src/resources/formats/ipynb/templates/title-block.md index 7ddab0bef5..cdfc650acc 100644 --- a/src/resources/formats/ipynb/templates/title-block.md +++ b/src/resources/formats/ipynb/templates/title-block.md @@ -1,6 +1,6 @@ $-- Be very careful about whitespace in this document - line breaks are very meaningful $-- and it is very easy to break the layout with poorly considered line breaks -# $title$ +$if(title)$# $title$$endif$ $if(subtitle)$$subtitle$$endif$ diff --git a/tests/docs/doc-layout/title-block-no-title.qmd b/tests/docs/doc-layout/title-block-no-title.qmd new file mode 100644 index 0000000000..3b18e512db --- /dev/null +++ b/tests/docs/doc-layout/title-block-no-title.qmd @@ -0,0 +1 @@ +hello world diff --git a/tests/smoke/render/render-title-block.test.ts b/tests/smoke/render/render-title-block.test.ts index c54ed26f68..5a45ec97cc 100644 --- a/tests/smoke/render/render-title-block.test.ts +++ b/tests/smoke/render/render-title-block.test.ts @@ -90,3 +90,13 @@ testRender(orcidIpynbAffilInput, "ipynb", true, [ matches: [/ORCID\s+profile\s+for\s+Norah\s+Jones/], }), ]); + +// ipynb: no title metadata should not produce an empty "# " header (#14693). +const noTitleInput = docs("doc-layout/title-block-no-title.qmd"); +const noTitleIpynbOutput = outputForInput(noTitleInput, "ipynb"); +testRender(noTitleInput, "ipynb", true, [ + ensureIpynbCellMatches(noTitleIpynbOutput.outputPath, { + cellType: "markdown", + noMatches: [/^#\s*$/m], + }), +]); From 6470787dd040cdca42222c7da31865130ed12327 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 15 Jul 2026 16:11:56 +0200 Subject: [PATCH 2/2] Update ipynb snapshot for 8356 test after empty title-header fix Snapshot predates removal of the empty "# " title header in ipynb output. --- tests/docs/smoke-all/2024/01/19/8356.ipynb.snapshot | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/docs/smoke-all/2024/01/19/8356.ipynb.snapshot b/tests/docs/smoke-all/2024/01/19/8356.ipynb.snapshot index 5c65cb6c55..bf5ab84b34 100644 --- a/tests/docs/smoke-all/2024/01/19/8356.ipynb.snapshot +++ b/tests/docs/smoke-all/2024/01/19/8356.ipynb.snapshot @@ -4,8 +4,6 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# \n", - "\n", "## hello\n", "\n", "\n",