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

quarto convert: support an option to retain empty code cells #11690

Open
cscheid opened this issue Dec 16, 2024 · 0 comments
Open

quarto convert: support an option to retain empty code cells #11690

cscheid opened this issue Dec 16, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request jupyter
Milestone

Comments

@cscheid
Copy link
Collaborator

cscheid commented Dec 16, 2024

Discussed in #11685

Originally posted by anandology December 14, 2024

Description

The quarto convert command when converting from qmd to ipynb, drops all the code cells which are empty. This may be fine in most use cases, there are cases where this is undesirable.

It would be nice to have an option to retain empty code cells as well.

Sample Use Case

I teach programming courses and I use quarto convert to generate ipynb files from qmd sources. These notebooks are used by the students of the course. The following is an example where empty cells are needed.

The following code creates a new function `square`.

```{python}
def square(x):
    return x*x
```

```{python}
square(4)
````

Can you try creating a new function `cube` to compute cube a of number 
in the following cell?

```{python}

```

Check if your `cube` function is working correctly by running the following examples.

```{python}
print(cube(2))
print(cube(3))
print(cube(4))
```

The issue

The third code cell in the above example gets dropped.

The work-around is to make the code cell not empty by adding a comment, but I would prefer to keep it empty.

The Code

The part of the code that drops empty cells is at:

https://github.com/quarto-dev/quarto-cli/blob/main/src/core/jupyter/jupyter.ts#L422

@cscheid cscheid added enhancement New feature or request jupyter labels Dec 16, 2024
@cscheid cscheid added this to the v1.7 milestone Dec 16, 2024
@cscheid cscheid self-assigned this Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request jupyter
Projects
None yet
Development

No branches or pull requests

1 participant