Commands to convert between .ipynb and .qmd#955
Commands to convert between .ipynb and .qmd#955seeM wants to merge 14 commits intoquarto-dev:mainfrom
.ipynb and .qmd#955Conversation
There was a problem hiding this comment.
This is looking great! I have three questions/thoughts:
- Can we improve how error messages get surfaced to the user in terms of escaping? For example, if I have a Quarto file like this:
---
title: "unclosed
format: html
---
content
And I run the new command, I get this popup, which is not ideal:
- When I convert a
.qmdto an.ipynb, it always opens up the new file in a regular text editor for the JSON, not a notebook editor:
Can we open the new .ipynb files in the default notebook editor the user has configured? Either the legacy one or the new Positron notebook editor?
- Can you update the CHANGELOG with info on this new feature?
…test config so it's easier to run alone and shows in vscode extension test runner ui
Register `quarto.convertToIpynb` and `quarto.convertToQmd` commands that wrap `quarto convert` to convert between .qmd and .ipynb formats. Includes overwrite confirmation, error handling with output channel logging, and editor context menus.
4f4103e to
b24fdb2
Compare
|
Thanks, great catches.
|
juliasilge
left a comment
There was a problem hiding this comment.
This is looking good and is ready to merge! 🙌
I want to highlight that if we start sticking a button for this on files in Positron, we are going to come up hard against some of what doesn't work well with quarto convert. There are a bunch of situations where it doesn't work well, but here is one example.
Make an R notebook:
Convert and you get this:
---
jupyter: python3
---
Here is my great notebook! It will use janitor 🧼🧹
```{python}
library(tidyverse)
library(janitor)
gapminder::gapminder |>
clean_names() |>
drop_na()
```
This isn't a problem with this PR but with quarto convert but we will want to be very careful about where we surface this functionality with a button. We want to only put it somewhere that we think it will work well. Maybe no R? And maybe no .qmd files, as the conversion from .qmd to .ipynb is worse than the other way IMO.
|
@juliasilge interesting. What do you think about us fixing those sorts of issues if they come up? |
|
@seeM Those would need to be fixed in the core of the Quarto CLI, not the extension: https://github.com/quarto-dev/quarto-cli/issues?q=is%3Aissue%20state%3Aopen%20%22quarto%20convert%22 You are advocating we fix them in the Quarto CLI?
|
|
You can read some more background here: https://github.com/orgs/quarto-dev/discussions/9463 |

Closes #6.
This PR adds two commands to convert between
.ipynband.qmdusing thequarto convertCLI. The motivation is to ease the onboarding process for Positron users coming from Jupyter Notebooks who are interested in trying out Quarto, and vice versa (posit-dev/positron#11865).Both commands are available in the command palette and in the UI:
quarto.convertToIpynb: available in source and visual editor overflow menus, under a new group at the bottomquarto.convertToQmd: available in notebook editor overflow menu (both VS Code notebook editor and Positron notebook editor), under a new group at the bottomThe commands follow the same process:
Tests are included.
In future, I plan to add a command to Positron tentatively named
quarto.initializeFromIpynbthat thequarto.convertToQmdcalls before opening the created.qmdfile to set the kernel binding and fill the output cache using the original.ipynbfile for a more seamless transition.