Open Walser52 opened 8 months ago
This is a very bad side effect of a Jupyter 'feature' because you have set no title
in your YAML
When there is no title in a document with Jupyter, the first header will be taken as a title in some condition. See related issue:
This was fixed in https://github.com/quarto-dev/quarto-cli/commit/24672a4affb8d3c881be9a3b9ede641d2e26d9d9 and commit message gives insights
We promote headings to notebook titles as this is a common pattern in ipynbs. Reducei the footprint where we do this to stop capturing so many headings.
Now we check on the first markdown cell and only do the promotion if there is no title specified and there is no content before the heading.
Providing a title:
solves this
If you plan on having your title slide with .center
as the first slide, then you'll need to wait for a fix here.
We need two things I believe
title
in YAML means to use a custom title slide (https://quarto.org/docs/presentations/revealjs/index.html#title-slide) because promoting the title will indeed create a new slide (undesired)cc @dragonstyle
Thanks for the report !
@dragonstyle we get the {.center}
that is passed in the title because the parsePandocTitle()
does not account for empty header. So the attribute part is not match.
This should be the change in regex
diff --git a/src/core/pandoc/pandoc-partition.ts b/src/core/pandoc/pandoc-partition.ts
index b02216553..57459eb15 100644
--- a/src/core/pandoc/pandoc-partition.ts
+++ b/src/core/pandoc/pandoc-partition.ts
@@ -18,7 +18,7 @@ export function firstHeadingFromMarkdown(markdown: string): string | undefined {
return partitioned.headingText;
}
-const kPandocTitleRegex = /^\#{1,}\s(.*)\s\{(.*)\}$/;
+const kPandocTitleRegex = /^\#{1,}\s(?:(.*)\s)?\{(.*)\}$/;
const kRemoveHeadingRegex = /^#{1,}\s*/;
export function parsePandocTitle(title: string) {
If we do that we get the correct fix behavior it seems because empty header does not create a new title slide alone.
However, it does not solve the problem that catching a header in revealjs presentation will separate from its content with
---
format:
revealjs:
engine: jupyter
---
## My custom title slide {.center}
Content
## Python slide
```{python}
1 + 1
gives this slide overview
![image](https://github.com/quarto-dev/quarto-cli/assets/6791940/266c4992-b1d6-417d-b81b-620bdf026f96)
IMO not good. From our discussion in #8016 I understand we get header inside document for a reason, but in revealjs context, this is not ok as header means section, and it relates with its content.
## {.center}
But there is still the issue of stripping the first header when no title, as it will split the initial slide in two.
I'd like to make the case for simply dropping this title promotion feature. Does it carry its own weight in terms of cost vs value?
It keeps on giving troubles, with differences of behavior between kernels, or even with the same kernel when code is executed vs not executed, and now maybe different behaviors for different output formats.
Then there's the complexity in the code due to this feature. From working on #7159 I got the impression that it's a lot.
Even from the user perspective and assuming zero bugs, it's arguably more valuable to have simple rules and consistent behavior across kernels and formats.
And it's even partially redundant: For the particular use case of quarto render existing_notebook.ipynb
we already have this:
quarto render existing_notebook.ipynb -M shift-heading-level-by=-1
which will promote an h1 heading to document title. It's consistent with pandoc, and explicit rather than "magically happens sometimes".
What do you think?
Does it carry its own weight in terms of cost vs value?
My understanding is that it's somewhat necessary for .ipynb inputs, where a title is often denoted as the first H1 element in the notebook.
But then it's also necessary to not have this feature, for rendering notebooks that don't follow this convention :-)
Maybe the feature could be made opt-in? I'm not sure it's necessary at all since it's easy to update the notebook to have a proper quarto title, and many cases are already covered by the shift-heading-level-by
option. But at least having it opt-in would solve the inconsistent behaviors mentioned in my previous comment...
We have a plan to solve this, but we've determined it carries a sufficient regression risk that we want to do it in 1.5 with plenty of room to address regressions.
Bug description
I want a revealJS presentation with no title slide. Removing the title and author info from the yaml header works but not if there is python code in there. The problem does not occur when I change the python code with R.
Steps to reproduce