Skip to content

Unexpected behaviour of heading following executable code block #12440

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

Open
jsquaredosquared opened this issue Apr 3, 2025 · 5 comments · May be fixed by #12549
Open

Unexpected behaviour of heading following executable code block #12440

jsquaredosquared opened this issue Apr 3, 2025 · 5 comments · May be fixed by #12549
Assignees
Labels
bug Something isn't working convert Related to quarto convert command jupyter
Milestone

Comments

@jsquaredosquared
Copy link

jsquaredosquared commented Apr 3, 2025

Bug description

If title is not explicitly set in the yaml frontmatter, the heading immediately following an executable code block (i.e., ```{python}) is used as the title of the document. This bug does not happen when the code block is not executable (i.e., ```python).

Steps to reproduce

InputOutput
---
format: typst
---

# This is what happens when I don't set the title.

## This is a level 2 heading

This is some paragraph text.

```{python}
# This is an executable Python code block.
print("This is the output of an executable Python code block.")
```

## This is another level 2 heading

This is some more paragraph text.

Image

Actual behavior

No response

Expected behavior

InputOutput
---
format: typst
title: Title
---

# This is what happens when I set the title.

## This is a level 2 heading

This is some paragraph text.

```{python}
# This is an executable Python code block.
print("This is the output of an executable Python code block.")
```

## This is another level 2 heading

This is some more paragraph text.

Image

Your environment

  • IDE: VSCode 1.98.2
  • OS: Linux Pop!_OS 22.04

Quarto check output

Quarto 1.6.42
[✓] Checking environment information...
      Quarto cache location: /home/jj/.cache/quarto
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.4.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.46.3: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.6.42
      Path: /opt/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: (not installed)
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Tex:  (not detected)

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.13.1
      Path: /home/jj/Desktop/quarto_bug/.venv/bin/python3
      Jupyter: 5.7.2
      Kernels: python3, coconut_py, coconut, coconut_py2, xonsh, coconut_py3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.4.3
      Path: /usr/lib/R
      LibPaths:
        - /home/jj/R/x86_64-pc-linux-gnu-library/4.4
        - /usr/local/lib/R/site-library
        - /usr/lib/R/site-library
        - /usr/lib/R/library
      knitr: 1.49
      rmarkdown: 2.29

[✓] Checking Knitr engine render......OK

maybe related to this issue? idk

@jsquaredosquared jsquaredosquared added the bug Something isn't working label Apr 3, 2025
@mcanouil
Copy link
Collaborator

mcanouil commented Apr 3, 2025

Thanks, I can reproduce on latest pre-release.

It's clearly not related to the issue you've linked. Remove the comment and you'll see the same thing.

It's about the Jupyter engine code path (no issues with both julia and knitr).

@cscheid cscheid self-assigned this Apr 4, 2025
@cscheid cscheid added this to the v1.7 milestone Apr 4, 2025
@cscheid cscheid added convert Related to quarto convert command and removed typst labels Apr 15, 2025
@cscheid
Copy link
Collaborator

cscheid commented Apr 15, 2025

Two calls to convert are sufficient to repro the bug.

@cscheid
Copy link
Collaborator

cscheid commented Apr 15, 2025

The bug happens with a combination of the following characteristics of an .ipynb file to be converted to .qmd:

  • a single markdown cell has metadata but not title
  • that same single markdown cell has an H1 heading with the implicit title
  • a different markdown cell has an H2 heading

What happens here, I think, is that if the code for title detection finds a YAML block, then it takes the lack of a title: field in that block to mean that the implicit title is not present in the entire cell. Then, the code searches for the next implicit title, which is the H2 heading two cells down.

@cscheid
Copy link
Collaborator

cscheid commented Apr 15, 2025

It's somewhat worse than that, but I have a fix incoming.

@cscheid cscheid modified the milestones: v1.7, v1.8 Apr 15, 2025
@cscheid
Copy link
Collaborator

cscheid commented Apr 15, 2025

Unfortunately this looks very messy to fix, and our test suite didn't like my attempt. To v1.8 it goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working convert Related to quarto convert command jupyter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants