|
1 | 1 | --- |
2 | 2 | title: VS Code Notebook Editor |
| 3 | +tool: |
| 4 | + name: VS Code |
| 5 | + image-prefix: images/vscode |
3 | 6 | --- |
4 | 7 |
|
5 | | -In addition to editing Quarto documents as plain-text `.qmd` files, you can also use the VS Code Notebook Editor to author `.ipynb` notebooks that are rendered with Quarto. In this article we'll review the basics of editing `.ipynb` notebooks for use with Quarto. |
6 | | - |
7 | | - |
8 | | -## Render and Preview |
9 | | - |
10 | | -The basic workflow for editing notebooks for use with Quarto is identical to the workflow for `.qmd` files. Edit the file and then execute the **Quarto: Preview** command (you can alternatively use the <kbd>Ctrl+Shift+K</kbd> keyboard shortcut). You'll see a preview of the published page side by side with the notebook: |
11 | | - |
12 | | -{.border} |
13 | | - |
14 | | -After you've done an initial **Quarto: Preview**, the preview will automatically update every time you save the notebook. |
15 | | - |
16 | | -## YAML Front Matter |
17 | | - |
18 | | -The first cell of your notebook should be a **Raw** cell that contains the document title, author, and any other options you need to specify. Note that you can switch the type of a cell to **Raw** using the cell type menu at the bottom right of the cell: |
19 | | - |
20 | | -{.border fig-alt="The top section of an ipynb file open in VSCode. There is a Raw cell containing yaml front matter."} |
21 | | - |
22 | | -In this example we specify that we want code to appear collapsed by default. There are YAML options to control many other aspects of document rendering. See the documentation on [Authoring](/docs/authoring/markdown-basics.qmd) and [Output Formats](/docs/output-formats/html-basics.qmd) for additional details. |
23 | | - |
24 | | -## Markdown Cells |
25 | | - |
26 | | -Here's the underlying code for the markdown cell: |
27 | | - |
28 | | -{.border fig-alt="A snippet of an ipynb document containing a Markdown cell. The cell contains some text written in Markdown."} |
29 | | - |
30 | | -Note that a Quarto cross-reference (`@fig-polar`) is included in the markdown. Any valid Pandoc markdown syntax can be included in markdown cells. |
31 | | - |
32 | | -## Output Options |
33 | | - |
34 | | -Quarto uses leading comments with a special prefix (`#|`) to denote cell options. Here we specify the `label` and `fig-cap` options so that the plot generated from the cell can be cross-referenced. |
35 | | - |
36 | | -{.border fig-alt="A snippet of a JupyterLab document containing a code cell. At the top of cell, before the code, are the Quarto chunk options '#| label: fig-polar' and '#| fig-cap: A line plot on a polar axis.'"} |
37 | | - |
38 | | -Note that options must appear at the very beginning of the cell. As with document front-matter, option names/values use YAML syntax. |
39 | | - |
40 | | -There are many output options available, including options to optionally hide code, warnings, and/or output. See the documentation on [Output Options](/docs/computations/execution-options.qmd#output-options) for additional details. |
41 | | - |
42 | | -## Cell Execution |
43 | | - |
44 | | -{{< include ../computations/_jupyter-execute.md >}} |
45 | | - |
46 | | -There are many other execution options available (e.g. to control caching, optimizing kernel start-up time, etc.). Learn more about these options in [Execution Options](/docs/computations/execution-options.qmd). |
47 | | - |
48 | | -## Converting Notebooks |
49 | | - |
50 | | -You can convert between .ipynb and .qmd representations of a notebook using the `quarto convert` command. For example: |
51 | | - |
52 | | -``` {.bash filename="Terminal"} |
53 | | -quarto convert basics-jupyter.ipynb |
54 | | -quarto convert basics-jupyter.qmd |
55 | | -``` |
56 | | - |
57 | | -See `quarto convert help` for additional details on converting notebooks. |
| 8 | +{{< include _code-oss_notebook.md >}} |
0 commit comments