Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve title snipping in notebooks for revealjs #8016

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions news/changelog-1.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@
- ([#7607](https://github.com/quarto-dev/quarto-cli/issues/7607)): Make `output: asis` behave the same way as the `knitr` engine, emitting div enclosures when necessary.
- ([#5363](https://github.com/quarto-dev/quarto-cli/issues/5363)): Fix issue caused by Quarto incorrectly using some headings as a title when reading notebooks.
- ([#6411](https://github.com/quarto-dev/quarto-cli/issues/6411)): Don't perform notebook title fixup if the project is providing a title.
- ([#8012](https://github.com/quarto-dev/quarto-cli/issues/8012)): Don't perform notebook title fixup with `format: revealjs` as this would create a new undesired title slide.

## Knitr

Expand Down
10 changes: 8 additions & 2 deletions src/core/jupyter/jupyter-fixups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,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) {
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 &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea of this is that a python user with existing notebooks may want to render them using quarto render foo.ipynb --to html or similar commands and get a reasonable experience. Since it is common to place a heading as the 'title' of the notebook in a markdown cell at the top of the notebook, we're trying to find the best way to promote that to the document title in Quarto.

It's pretty tempting to just that if the user creates front matter at all, they should place a title there (not just for revealJS - just that once they're making front matter we expect them to handle the title)...

We could start with this if you're feeling conservative.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The revealjs specific case is that

  • Using title will trigger the use of a specific title-slide sectionf from the revealjs template
  • To opt out this title slide from the template, no providing title in YAML is for now the way to go.

Currently it seems you can't do that with engine: jupyter, or at least that we promote headers like ## without considering the slide-level, meaning that a non section slide could be promoted to section slide.

This is something quite specific to revealjs here related to this heading promoting feature. 🤔

(yaml?.format === "revealjs" ||
(typeof yaml?.format === "object" && "revealjs" in yaml?.format)))
) {
return nb;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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)
```