Skip to content

Commit 2e66958

Browse files
authored
Fix ipynb rendering an empty title header when no title is set (#14697)
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. Update ipynb snapshot for 8356 test after empty title-header fix
1 parent c284199 commit 2e66958

5 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎news/changelog-1.10.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ All changes included in 1.10:
4949

5050
- ([#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).
5151

52+
### `ipynb`
53+
54+
- ([#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`.
55+
5256
## Projects
5357

5458
### Manuscripts

‎src/resources/formats/ipynb/templates/title-block.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
$-- Be very careful about whitespace in this document - line breaks are very meaningful
22
$-- and it is very easy to break the layout with poorly considered line breaks
3-
# $title$
3+
$if(title)$# $title$$endif$
44

55
$if(subtitle)$$subtitle$$endif$
66

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello world

‎tests/docs/smoke-all/2024/01/19/8356.ipynb.snapshot‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# \n",
8-
"\n",
97
"## hello\n",
108
"\n",
119
"<table>\n",

‎tests/smoke/render/render-title-block.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,13 @@ testRender(orcidIpynbAffilInput, "ipynb", true, [
9090
matches: [/ORCID\s+profile\s+for\s+Norah\s+Jones/],
9191
}),
9292
]);
93+
94+
// ipynb: no title metadata should not produce an empty "# " header (#14693).
95+
const noTitleInput = docs("doc-layout/title-block-no-title.qmd");
96+
const noTitleIpynbOutput = outputForInput(noTitleInput, "ipynb");
97+
testRender(noTitleInput, "ipynb", true, [
98+
ensureIpynbCellMatches(noTitleIpynbOutput.outputPath, {
99+
cellType: "markdown",
100+
noMatches: [/^#\s*$/m],
101+
}),
102+
]);

0 commit comments

Comments
 (0)