### Bug description

We can convert between .ipynb and .qmd representations of a notebook using the quarto convert command.

However, some notebooks have custom directives. These are normally supported during project compilation using the `ipynb-filters` option in `_quarto.yml` and are essential to the nbdev project where directives such as `#|export` select code cells for compilation into a python library.

`quarto convert` doesn't work on notebooks designed to make use of this advanced feature. 

If an ipynb file had the code cell:

```python
#| export
import numpy as np
```

converting it into QMD will produce the cell:

```python
#| '0': e
#| '1': x
#| '2': p
#| '3': o
#| '4': r
#| '5': t
import numpy as np
```

and converting back will discard the directive completely:

```python
import numpy as np
```

Starting out with a correct `#|export` directive in the QMD version of the file and attempting to convert the file into ipynb produces the following error:

```
> ERROR: TypeError: Cannot delete property '0' of [object String]
```

Ideally what would happen during a round-trip conversion is that the directives included at the top of code cells are preserved, just as natively supported directives are presented.

If quarto convert or some other tool could handle the round trip conversion between ipynb and qmd more cleanly, then nbdev projects and other tools utilizing the advanced nb-filter feature could use qmd source files for their work instead of jupyter notebooks! And the advantages of QMD over IPYNB as a format for work mixing text and code probably don't need to be outlined here.

Simple example file that quarto convert will struggle with:
https://gist.githubusercontent.com/githubpsyche/32c6391c30699bfd103b4992743b0af3/raw/a17f651cc28a9bb4f3afeab14bb9259ebc0bd0f6/example.ipynb

Using Windows 11. I believe I've tried this with the current release 1.1.251 and 1.2.253.

### Checklist

- [X] Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
- [X] Please [format your issue](https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us) so it is easier for us to read the bug report.
- [X] Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- [X] Please document the operating system you're running. If on Linux, please provide the specific distribution.
cscheid
2022-11-03T08:50:05Z
githubpsyche
bug
v1.3
closed
custom directives / ipynb-filters during quarto convert
https://github.com/quarto-dev/quarto-cli/issues/3152