diff --git a/news/changelog-1.10.md b/news/changelog-1.10.md index d3422010c4e..c645725178f 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 7ddab0bef53..cdfc650accb 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 00000000000..3b18e512dba --- /dev/null +++ b/tests/docs/doc-layout/title-block-no-title.qmd @@ -0,0 +1 @@ +hello world 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 5c65cb6c553..bf5ab84b347 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", diff --git a/tests/smoke/render/render-title-block.test.ts b/tests/smoke/render/render-title-block.test.ts index c54ed26f681..5a45ec97cc8 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], + }), +]);