Commands to convert between .ipynb and .qmd#955
Commands to convert between .ipynb and .qmd#955seeM wants to merge 6 commits intoquarto-dev:mainfrom
.ipynb and .qmd#955Conversation
…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', |
There was a problem hiding this comment.
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.
| { | ||
| "command": "quarto.convertToQmd", | ||
| "title": "Convert Notebook to .qmd", | ||
| "category": "Notebook" |
There was a problem hiding this comment.
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
| "group": "q_zPreview" | ||
| }, | ||
| { | ||
| "command": "quarto.convertToQmd", |
There was a problem hiding this comment.
~~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 |
There was a problem hiding this comment.
No longer needed given the filter change in .vscode-test.mjs
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?
| * @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` |
There was a problem hiding this comment.
Can we correct the doc comment here, for what this function actually returns?
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.