Skip to content

Commands to convert between .ipynb and .qmd#955

Open
seeM wants to merge 6 commits intoquarto-dev:mainfrom
seeM:feat/vscode-convert-command
Open

Commands to convert between .ipynb and .qmd#955
seeM wants to merge 6 commits intoquarto-dev:mainfrom
seeM:feat/vscode-convert-command

Conversation

@seeM
Copy link
Copy Markdown
Contributor

@seeM seeM commented Apr 26, 2026

Closes #6.

This PR adds two commands to convert between .ipynb and .qmd using the quarto convert CLI. 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 bottom
  • quarto.convertToQmd: available in notebook editor overflow menu (both VS Code notebook editor and Positron notebook editor), under a new group at the bottom

The commands follow the same process:

  1. Save the document
  2. Check if converting would overwrite a file and prompt the user with a modal dialogue
  3. Convert the document
  4. Show any tidied up CLI errors
  5. Open the converted document

Tests are included.

In future, I plan to add a command to Positron tentatively named quarto.initializeFromIpynb that the quarto.convertToQmd calls before opening the created .qmd file to set the kernel binding and fill the output cache using the original .ipynb file for a more seamless transition.

seeM added 2 commits April 23, 2026 21:54
…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.
{
files: 'test-out/*.test.js',
label: 'main',
files: 'test-out/!(r-project).test.js',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This correctly filters out the r-project test which has its own configuration below and which currently skips when run from the main configuration.

The label is to more easily run only this configuration - before this change it uses the default --label 0.

Comment thread apps/vscode/package.json
{
"command": "quarto.convertToQmd",
"title": "Convert Notebook to .qmd",
"category": "Notebook"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Using the Notebook category for the .ipynb -> .qmd command because that's what most notebook commands use, so I expect it to be more discoverable

Comment thread apps/vscode/package.json
"group": "q_zPreview"
},
{
"command": "quarto.convertToQmd",
Copy link
Copy Markdown
Contributor Author

@seeM seeM Apr 26, 2026

Choose a reason for hiding this comment

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

~~This should show up correctly in VS Code and in the legacy notebook editor in Positron.

The Positron notebook editor doesn't connect to the notebook/toolbar menu so it'll need additional work to show up there.~~

Nvm, it should work everywhere! I didn't realize that editor/title menu items already appear in the Positron notebook editor.

// projects with a top-level `DESCRIPTION` file.

suite("Workspace Symbols - R Project", function () {
// Return early if we're running with the regular test configuration
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No longer needed given the filter change in .vscode-test.mjs

@cderv cderv requested a review from cscheid April 27, 2026 08:23
Copy link
Copy Markdown
Collaborator

@juliasilge juliasilge left a comment

Choose a reason for hiding this comment

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

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:

Image
  • When I convert a .qmd to an .ipynb, it always opens up the new file in a regular text editor for the JSON, not a notebook editor:
Image

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?

* @param outputChannel Output channel for logging errors
* @param sourceUri URI of the document to convert
* @param targetExt Target extension for the converted file (e.g. ".ipynb", ".qmd")
* @returns URI of the converted file if successful, otherwise `undefined`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we correct the doc comment here, for what this function actually returns?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add quarto convert command

2 participants