{"version":3,"kind":"Notebook","sha256":"cc73e7acebb2d152051e62a2f8fc265d1efc7b0231d5b7aa27823ac051a7d0bc","slug":"executable","location":"/content/lessons/executable.md","dependencies":[],"frontmatter":{"title":"Executable content introduction","numbering":{"title":{"offset":0,"enabled":true}},"kernelspec":{"name":"python3","display_name":"Python 3"},"content_includes_title":false,"authors":[{"nameParsed":{"literal":"Freek Pols","given":"Freek","family":"Pols"},"name":"Freek Pols","id":"contributors-myst-generated-uid-0"},{"nameParsed":{"literal":"Luuk Fröling","given":"Luuk","family":"Fröling"},"name":"Luuk Fröling","id":"contributors-myst-generated-uid-1"},{"nameParsed":{"literal":"Robert Lanzafame","given":"Robert","family":"Lanzafame"},"name":"Robert Lanzafame","id":"contributors-myst-generated-uid-2"},{"nameParsed":{"literal":"Kirstie Whitaker","given":"Kirstie","family":"Whitaker"},"name":"Kirstie Whitaker","id":"contributors-myst-generated-uid-3"},{"nameParsed":{"literal":"Jim Madge","given":"Jim","family":"Madge"},"name":"Jim Madge","id":"contributors-myst-generated-uid-4"}],"date":"2025-11-02","license":{"content":{"id":"CC-BY-4.0","url":"https://creativecommons.org/licenses/by/4.0/","name":"Creative Commons Attribution 4.0 International","free":true,"CC":true}},"github":"https://github.com/jupyter-book/workshop-template","edit_url":null,"abbreviations":{"JB2":"Jupyter Book 2","CI/CD":"Continuous Integration/Continuous Deployment","GHA":"GitHub Actions","GH":"GitHub","IDE":"Integrated Development Environment","VSC":"Visual Studio Code","CLI":"commmand line interface"},"source_url":"https://github.com/jupyter-book/workshop-template/blob/main/content/lessons/executable.md","enumerator":"6","exports":[{"format":"md","filename":"executable.md","url":"/build/executable-56cc3814ef5fda1f1f0835bfbd1915a1.md"}]},"mdast":{"type":"root","children":[{"type":"div","class":"font-light text-sm mb-4 updated-date-container","children":[{"type":"text","value":"Updated: 03 Nov 2025","key":"N3NfDoPCwL"}],"key":"PCiK00hK4q"},{"type":"block","children":[{"type":"paragraph","position":{"start":{"line":12,"column":1},"end":{"line":12,"column":1}},"children":[{"type":"text","value":"MyST supports a number of ways to include executable content in your project.","position":{"start":{"line":12,"column":1},"end":{"line":12,"column":1}},"key":"Tjv3n7QyI8"}],"key":"W5Xxq43Z3p"},{"type":"admonition","kind":"tip","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Tip","key":"oWmdlWPmMd"}],"key":"elKs0ExzD7"},{"type":"paragraph","position":{"start":{"line":15,"column":1},"end":{"line":15,"column":1}},"children":[{"type":"text","value":"Instructions are provided here for Jupyter Lab, however, you can use any ","key":"cVJRrFEGQb"},{"type":"abbreviation","title":"Integrated Development Environment","children":[{"type":"text","value":"IDE","key":"LPX62K89dE"}],"key":"UT2PvkUR2t"},{"type":"text","value":" you are comfortable with. An explanation is provided on the ","key":"UZSbvsmex3"},{"type":"link","position":{"start":{"line":15,"column":1},"end":{"line":15,"column":1}},"children":[{"type":"text","value":"Software","position":{"start":{"line":15,"column":1},"end":{"line":15,"column":1}},"key":"rgvdlAheio"}],"identifier":"software","label":"software","url":"/software","internal":true,"dataUrl":"/software.json","key":"XUr7e0lwve"},{"type":"text","value":" page.","position":{"start":{"line":15,"column":1},"end":{"line":15,"column":1}},"key":"i1rT04AUsz"}],"key":"nlXtN7QYPM"}],"key":"Gj48c6h1mj"},{"type":"heading","depth":2,"position":{"start":{"line":18,"column":1},"end":{"line":18,"column":1}},"children":[{"type":"text","value":"Installing Jupyter","position":{"start":{"line":18,"column":1},"end":{"line":18,"column":1}},"key":"tZso0r9OOG"}],"identifier":"installing-jupyter","label":"Installing Jupyter","html_id":"installing-jupyter","implicit":true,"key":"V8KI2N5wqG"},{"type":"paragraph","position":{"start":{"line":20,"column":1},"end":{"line":21,"column":1}},"children":[{"type":"text","value":"Executable content in MyST is processed by a ","position":{"start":{"line":20,"column":1},"end":{"line":20,"column":1}},"key":"iERZuzXjhB"},{"type":"link","url":"https://docs.jupyter.org/en/latest","position":{"start":{"line":20,"column":1},"end":{"line":20,"column":1}},"children":[{"type":"text","value":"Jupyter","position":{"start":{"line":20,"column":1},"end":{"line":20,"column":1}},"key":"D813vlcgDH"}],"urlSource":"xref:jupyter","internal":false,"protocol":"xref:sphinx","key":"eF9lHtSCqK"},{"type":"text","value":" server and appropriate ","position":{"start":{"line":20,"column":1},"end":{"line":20,"column":1}},"key":"sB5fJJhG8o"},{"type":"link","url":"https://docs.jupyter.org/en/latest/glossary.html#term-kernel","position":{"start":{"line":20,"column":1},"end":{"line":20,"column":1}},"children":[{"type":"text","value":"kernel","position":{"start":{"line":20,"column":1},"end":{"line":20,"column":1}},"key":"Xz19MAPWoX"}],"urlSource":"https://docs.jupyter.org/en/latest/glossary.html#term-kernel","key":"G9aB7Vgtun"},{"type":"text","value":".\nIn this lesson, we will run a local Jupyter server to execute code cells.","position":{"start":{"line":20,"column":1},"end":{"line":20,"column":1}},"key":"hUWkYOLxHM"}],"key":"PI0z8PrFqn"},{"type":"paragraph","position":{"start":{"line":23,"column":1},"end":{"line":24,"column":1}},"children":[{"type":"text","value":"A pip requirements file, ","position":{"start":{"line":23,"column":1},"end":{"line":23,"column":1}},"key":"Q0wmrFIcDB"},{"type":"inlineCode","value":"requirements.txt","position":{"start":{"line":23,"column":1},"end":{"line":23,"column":1}},"key":"ym9ajt7S4b"},{"type":"text","value":" in the root of the repository specifies all of the dependencies you need.\nYou can install all of these in a virtual environment using ","position":{"start":{"line":23,"column":1},"end":{"line":23,"column":1}},"key":"KM2SqFFJ9m"},{"type":"inlineCode","value":"pip","position":{"start":{"line":23,"column":1},"end":{"line":23,"column":1}},"key":"uUfY3l4Hug"},{"type":"text","value":" and then launch Jupyter.","position":{"start":{"line":23,"column":1},"end":{"line":23,"column":1}},"key":"etASshxeJ8"}],"key":"O6JUZiWavR"},{"type":"tabSet","children":[{"type":"tabItem","title":"Linux and MacOS","children":[{"type":"code","lang":"console","value":"python3 -m venv ./venv\nsource ./venv/bin/activate\npip install -r requirements.txt\njupyter lab","position":{"start":{"line":28,"column":1},"end":{"line":33,"column":1}},"key":"u6XBrjFjSh"}],"key":"syG6a6tF2j"},{"type":"tabItem","title":"Windows","children":[{"type":"code","lang":"console","value":"python -m venv venv","position":{"start":{"line":36,"column":1},"end":{"line":38,"column":1}},"key":"ELpdiNyMid"},{"type":"paragraph","position":{"start":{"line":40,"column":1},"end":{"line":40,"column":1}},"children":[{"type":"text","value":"For Command Prompt","position":{"start":{"line":40,"column":1},"end":{"line":40,"column":1}},"key":"nhyrCffuaD"}],"key":"iB5xmB2PYU"},{"type":"code","lang":"console","value":"venv\\Scripts\\activate.bat","position":{"start":{"line":42,"column":1},"end":{"line":44,"column":1}},"key":"cyIuzZK1tp"},{"type":"paragraph","position":{"start":{"line":46,"column":1},"end":{"line":46,"column":1}},"children":[{"type":"text","value":"For PowerShell","position":{"start":{"line":46,"column":1},"end":{"line":46,"column":1}},"key":"vt5KDzv38o"}],"key":"WRkRVns0bg"},{"type":"code","lang":"console","value":"venv\\Scripts\\activate.ps1","position":{"start":{"line":48,"column":1},"end":{"line":50,"column":1}},"key":"mf3Nm7mSIk"},{"type":"paragraph","position":{"start":{"line":52,"column":1},"end":{"line":52,"column":1}},"children":[{"type":"text","value":"Then","position":{"start":{"line":52,"column":1},"end":{"line":52,"column":1}},"key":"ykegYd4Epl"}],"key":"A2zkmseDzL"},{"type":"code","lang":"console","value":"pip install -r requirements.txt\njupyter lab","position":{"start":{"line":54,"column":1},"end":{"line":57,"column":1}},"key":"tkTjubZ6z7"}],"key":"RmCqWUpqk1"}],"key":"iWSBpHWuI4"},{"type":"paragraph","position":{"start":{"line":61,"column":1},"end":{"line":61,"column":1}},"children":[{"type":"text","value":"This will automatically open the Jupyter Lab interface (at ","position":{"start":{"line":61,"column":1},"end":{"line":61,"column":1}},"key":"LhcQPJZGFH"},{"type":"link","url":"http://localhost:8888","position":{"start":{"line":61,"column":1},"end":{"line":61,"column":1}},"children":[{"type":"text","value":"localhost:8888","position":{"start":{"line":61,"column":1},"end":{"line":61,"column":1}},"key":"CoaDgXcia1"}],"urlSource":"http://localhost:8888","key":"hB7fFjsruN"},{"type":"text","value":") in your browser, which we will use later.","position":{"start":{"line":61,"column":1},"end":{"line":61,"column":1}},"key":"k7C4L6JD2G"}],"key":"EoVmh2n9LY"},{"type":"admonition","kind":"tip","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Using GitHub actions","position":{"start":{"line":63,"column":1},"end":{"line":63,"column":1}},"key":"L3qVfTKniW"}],"key":"JmKN6QyAYx"},{"type":"paragraph","position":{"start":{"line":64,"column":1},"end":{"line":64,"column":1}},"children":[{"type":"text","value":"One can use GitHub Actions to execute content at build time on GitHub servers as well, see an example ","position":{"start":{"line":64,"column":1},"end":{"line":64,"column":1}},"key":"GFHeDF84fX"},{"type":"inlineCode","value":"deploy.yml","position":{"start":{"line":64,"column":1},"end":{"line":64,"column":1}},"key":"oh80UTt7w7"},{"type":"text","value":" ","position":{"start":{"line":64,"column":1},"end":{"line":64,"column":1}},"key":"OivexFyOBM"},{"type":"crossReference","position":{"start":{"line":64,"column":1},"end":{"line":64,"column":1}},"children":[{"type":"text","value":"below","position":{"start":{"line":64,"column":1},"end":{"line":64,"column":1}},"key":"yKRw1fUoxC"}],"identifier":"gha-example","label":"GHA-example","kind":"heading","template":"{name}","resolved":true,"html_id":"gha-example","key":"fZ9ZSCLjfO"},{"type":"text","value":". More on the GitHub actions in the next lesson.","position":{"start":{"line":64,"column":1},"end":{"line":64,"column":1}},"key":"aAWrgJ5vmO"}],"key":"PvavXbRy4P"}],"key":"x1WyEyElpx"},{"type":"heading","depth":2,"position":{"start":{"line":67,"column":1},"end":{"line":67,"column":1}},"children":[{"type":"text","value":"Options","position":{"start":{"line":67,"column":1},"end":{"line":67,"column":1}},"key":"G6Qydh0W1A"}],"identifier":"options","label":"Options","html_id":"options","implicit":true,"key":"hSCLGEqZKq"},{"type":"heading","depth":3,"position":{"start":{"line":69,"column":1},"end":{"line":69,"column":1}},"children":[{"type":"text","value":"Jupyter Notebook outputs","position":{"start":{"line":69,"column":1},"end":{"line":69,"column":1}},"key":"W1SUA49HlT"}],"identifier":"jupyter-notebook-outputs","label":"Jupyter Notebook outputs","html_id":"jupyter-notebook-outputs","implicit":true,"key":"WdNaeVZWXz"},{"type":"paragraph","position":{"start":{"line":71,"column":1},"end":{"line":75,"column":1}},"children":[{"type":"text","value":"MyST can use Jupyter notebooks, ","position":{"start":{"line":71,"column":1},"end":{"line":71,"column":1}},"key":"hgubqzE3xe"},{"type":"inlineCode","value":".ipynb","position":{"start":{"line":71,"column":1},"end":{"line":71,"column":1}},"key":"ac0691eKXM"},{"type":"text","value":" files, as input just like Markdown.\nIf you have a notebook which you have executed, you can add it to the book.\nMarkdown cells will be rendered in exactly the same way as a Markdown file.\nSo you can use all of the MyST Markdown you have already learned.\nOutputs such as images and interactive plots will also be rendered in the book.","position":{"start":{"line":71,"column":1},"end":{"line":71,"column":1}},"key":"fKivJAn2hx"}],"key":"Kkx0quGSPn"},{"type":"paragraph","position":{"start":{"line":78,"column":1},"end":{"line":78,"column":1}},"children":[{"type":"text","value":"Blocks can be labelled, either by editing a cell’s JSON metadata, or with the following syntax,","position":{"start":{"line":78,"column":1},"end":{"line":78,"column":1}},"key":"bcjf5msg5v"}],"label":"label-notebooks","identifier":"label-notebooks","html_id":"label-notebooks","key":"dQl3KWJNtE"},{"type":"code","lang":"python","value":"#| label: my-label","position":{"start":{"line":80,"column":1},"end":{"line":82,"column":1}},"key":"bMPCHkhDPs"},{"type":"paragraph","position":{"start":{"line":84,"column":1},"end":{"line":84,"column":1}},"children":[{"type":"text","value":"Labels are particularly useful when integrating notebooks into larger documents such as theses or technical reports. By assigning labels to code blocks, and their corresponding outputs, you can reference them directly within your text, making it clear which code produced which figure, table, or result. ","position":{"start":{"line":84,"column":1},"end":{"line":84,"column":1}},"key":"Lqx4lPG3SC"},{"type":"link","url":"https://luukfroling.github.io/BEP/#visualisation-reconstruction","position":{"start":{"line":84,"column":1},"end":{"line":84,"column":1}},"children":[{"type":"text","value":"This example","position":{"start":{"line":84,"column":1},"end":{"line":84,"column":1}},"key":"mLlCaq4gWD"}],"urlSource":"https://luukfroling.github.io/BEP/#visualisation-reconstruction","key":"mT9DtJi9Se"},{"type":"text","value":" makes use of labels to reference figures from the Python notebook.","position":{"start":{"line":84,"column":1},"end":{"line":84,"column":1}},"key":"aVloVYDJfi"}],"key":"wAVdSHzToW"},{"type":"admonition","kind":"note","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Note","key":"IipnbydRDi"}],"key":"R5q692Rzvh"},{"type":"paragraph","position":{"start":{"line":87,"column":1},"end":{"line":89,"column":1}},"children":[{"type":"text","value":"This is the syntax for Python, where ","position":{"start":{"line":87,"column":1},"end":{"line":87,"column":1}},"key":"kT8pk9kp4K"},{"type":"inlineCode","value":"#","position":{"start":{"line":87,"column":1},"end":{"line":87,"column":1}},"key":"IDfwbnTKk3"},{"type":"text","value":" is the comment character.\nFor other languages, the syntax is the comment character followed by ","position":{"start":{"line":87,"column":1},"end":{"line":87,"column":1}},"key":"T4jDmpd4H1"},{"type":"inlineCode","value":"|","position":{"start":{"line":87,"column":1},"end":{"line":87,"column":1}},"key":"HTA5VaFvCF"},{"type":"text","value":".\nIn Javascript, for example, the above label would be,","position":{"start":{"line":87,"column":1},"end":{"line":87,"column":1}},"key":"VILGHNkp2L"}],"key":"pV8dFzqPXH"},{"type":"code","lang":"","value":"//| label: my-label","position":{"start":{"line":91,"column":1},"end":{"line":93,"column":1}},"key":"V4vR8GxhDG"}],"key":"CAK1FtZZLM"},{"type":"paragraph","position":{"start":{"line":96,"column":1},"end":{"line":96,"column":1}},"children":[{"type":"text","value":"Figures can be given a caption in a similar way,","position":{"start":{"line":96,"column":1},"end":{"line":96,"column":1}},"key":"qavXew585o"}],"key":"nRniJhrusy"},{"type":"code","lang":"python","value":"#| caption: Caption text","position":{"start":{"line":98,"column":1},"end":{"line":100,"column":1}},"key":"FxXF7S72fO"},{"type":"paragraph","position":{"start":{"line":102,"column":1},"end":{"line":102,"column":1}},"children":[{"type":"text","value":"We will explore using Jupyter notebooks as input for MyST in ","position":{"start":{"line":102,"column":1},"end":{"line":102,"column":1}},"key":"z2pfqjped0"},{"type":"crossReference","position":{"start":{"line":102,"column":1},"end":{"line":102,"column":1}},"children":[{"type":"text","value":"Adding a Jupyter Notebook","position":{"start":{"line":119,"column":1},"end":{"line":119,"column":1}},"key":"VyAbLMZvtt"}],"identifier":"lesson-exec-jupyternb","label":"lesson-exec-jupyternb","kind":"heading","template":"{name}","resolved":true,"html_id":"lesson-exec-jupyternb","key":"V8iB0Kgggt"},{"type":"text","value":".","position":{"start":{"line":102,"column":1},"end":{"line":102,"column":1}},"key":"u43SQmFe1T"}],"key":"ml7ASxvM3V"},{"type":"heading","depth":3,"position":{"start":{"line":104,"column":1},"end":{"line":104,"column":1}},"children":[{"type":"text","value":"Executing at build time","position":{"start":{"line":104,"column":1},"end":{"line":104,"column":1}},"key":"Q5IUe3aXa2"}],"identifier":"executing-at-build-time","label":"Executing at build time","html_id":"executing-at-build-time","implicit":true,"key":"ATkbKUusAo"},{"type":"paragraph","position":{"start":{"line":106,"column":1},"end":{"line":107,"column":1}},"children":[{"type":"text","value":"MyST can also execute content at build time, through connecting to a Jupyter server.\nExecutable cells can be in the ","position":{"start":{"line":106,"column":1},"end":{"line":106,"column":1}},"key":"j5hHTa6m19"},{"type":"inlineCode","value":".ipynb","position":{"start":{"line":106,"column":1},"end":{"line":106,"column":1}},"key":"yaMaFiEkPw"},{"type":"text","value":" format as well as written in Markdown using either the ","position":{"start":{"line":106,"column":1},"end":{"line":106,"column":1}},"key":"fepIlqFasH"},{"type":"crossReference","url":"/notebooks-with-markdown","position":{"start":{"line":106,"column":1},"end":{"line":106,"column":1}},"children":[{"type":"inlineCode","value":"code-cell","position":{"start":{"line":106,"column":1},"end":{"line":106,"column":1}},"key":"wkPkNGSp3B"},{"type":"text","value":" directive","position":{"start":{"line":106,"column":1},"end":{"line":106,"column":1}},"key":"ZrDSDaErs0"}],"urlSource":"xref:myst-guide/notebooks-with-markdown#code-cell","remote":true,"remoteBaseUrl":"https://mystmd.org/guide","dataUrl":"/notebooks-with-markdown.json","identifier":"code-cell","label":"code-cell","html_id":"code-cell","protocol":"xref:myst","template":"{name}","resolved":true,"key":"gRJAodvdtF"},{"type":"text","value":" or ","position":{"start":{"line":106,"column":1},"end":{"line":106,"column":1}},"key":"yJGePWSzBU"},{"type":"crossReference","url":"/notebooks-with-markdown","position":{"start":{"line":106,"column":1},"end":{"line":106,"column":1}},"children":[{"type":"inlineCode","value":"eval","position":{"start":{"line":106,"column":1},"end":{"line":106,"column":1}},"key":"IzNV8W1DcI"},{"type":"text","value":" role","position":{"start":{"line":106,"column":1},"end":{"line":106,"column":1}},"key":"rzywuA0rU2"}],"urlSource":"xref:myst-guide/notebooks-with-markdown#myst-inline-expressions","remote":true,"remoteBaseUrl":"https://mystmd.org/guide","dataUrl":"/notebooks-with-markdown.json","identifier":"myst:inline-expressions","label":"myst:inline-expressions","html_id":"myst-inline-expressions","protocol":"xref:myst","template":"{name}","resolved":true,"key":"U3SvIO6evW"},{"type":"text","value":".","position":{"start":{"line":106,"column":1},"end":{"line":106,"column":1}},"key":"ZAeZUfbhJ7"}],"key":"onjwhlbY9q"},{"type":"paragraph","position":{"start":{"line":109,"column":1},"end":{"line":109,"column":1}},"children":[{"type":"text","value":"We will cover executing at build time with Jupyter Notebooks in ","position":{"start":{"line":109,"column":1},"end":{"line":109,"column":1}},"key":"O5fvNpRyzp"},{"type":"crossReference","position":{"start":{"line":109,"column":1},"end":{"line":109,"column":1}},"children":[{"type":"text","value":"Adding a Jupyter Notebook","position":{"start":{"line":119,"column":1},"end":{"line":119,"column":1}},"key":"xYbFPuWD57"}],"identifier":"lesson-exec-jupyternb","label":"lesson-exec-jupyternb","kind":"heading","template":"{name}","resolved":true,"html_id":"lesson-exec-jupyternb","key":"vdMFa4836Y"},{"type":"text","value":", and with Markdown in ","position":{"start":{"line":109,"column":1},"end":{"line":109,"column":1}},"key":"EKFOjMeAoK"},{"type":"crossReference","position":{"start":{"line":109,"column":1},"end":{"line":109,"column":1}},"children":[{"type":"text","value":"Executable Markdown","position":{"start":{"line":162,"column":1},"end":{"line":162,"column":1}},"key":"Alx7kEp175"}],"identifier":"lesson-exec-markdown","label":"lesson-exec-markdown","kind":"heading","template":"{name}","resolved":true,"html_id":"lesson-exec-markdown","key":"kivbFanXXE"},{"type":"text","value":".","position":{"start":{"line":109,"column":1},"end":{"line":109,"column":1}},"key":"QNGEuEhAwz"}],"key":"GbivR1UXTe"},{"type":"heading","depth":3,"position":{"start":{"line":111,"column":1},"end":{"line":111,"column":1}},"children":[{"type":"text","value":"In page execution","position":{"start":{"line":111,"column":1},"end":{"line":111,"column":1}},"key":"aIcpGniHrh"}],"identifier":"in-page-execution","label":"In page execution","html_id":"in-page-execution","implicit":true,"key":"CrhbfGQNbf"},{"type":"paragraph","position":{"start":{"line":113,"column":1},"end":{"line":114,"column":1}},"children":[{"type":"text","value":"Through connecting your site to a remote Jupyter, it is also possible to execute code cells live, in the browser.\nThis feature is excellent for presenting readers with interactive elements, such as data science workflows they can follow along, or exercises where they are invited to change code.","position":{"start":{"line":113,"column":1},"end":{"line":113,"column":1}},"key":"nIYlKdqZiZ"}],"key":"Tbt1npajxk"},{"type":"paragraph","position":{"start":{"line":116,"column":1},"end":{"line":116,"column":1}},"children":[{"type":"text","value":"In page execution is not covered in this lesson.","position":{"start":{"line":116,"column":1},"end":{"line":116,"column":1}},"key":"lBXsWwyGbf"}],"key":"eTYwBYfe76"},{"type":"heading","depth":2,"position":{"start":{"line":119,"column":1},"end":{"line":119,"column":1}},"children":[{"type":"text","value":"Adding a Jupyter Notebook","position":{"start":{"line":119,"column":1},"end":{"line":119,"column":1}},"key":"PfonPzw4JT"}],"label":"lesson-exec-jupyternb","identifier":"lesson-exec-jupyternb","html_id":"lesson-exec-jupyternb","key":"yq5u2ItCvT"},{"type":"paragraph","position":{"start":{"line":121,"column":1},"end":{"line":121,"column":1}},"children":[{"type":"text","value":"In this repository we have included a Jupyter notebook, ","position":{"start":{"line":121,"column":1},"end":{"line":121,"column":1}},"key":"AzBG92ndcB"},{"type":"inlineCode","value":"example.ipynb","position":{"start":{"line":121,"column":1},"end":{"line":121,"column":1}},"key":"vWJgAZO1Lq"},{"type":"text","value":", which has been executed and includes outputs.","position":{"start":{"line":121,"column":1},"end":{"line":121,"column":1}},"key":"BUvIHKs9KM"}],"key":"FlIwiiY4UV"},{"type":"exercise","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Add a ","position":{"start":{"line":123,"column":1},"end":{"line":123,"column":1}},"key":"tDifi5i8il"},{"type":"inlineCode","value":".ipynb","position":{"start":{"line":123,"column":1},"end":{"line":123,"column":1}},"key":"hiASLWFkJL"},{"type":"text","value":" file to the book","position":{"start":{"line":123,"column":1},"end":{"line":123,"column":1}},"key":"MFxmBh3XRr"}],"key":"EXvDSAUQUs"},{"type":"paragraph","position":{"start":{"line":124,"column":1},"end":{"line":125,"column":1}},"children":[{"type":"text","value":"Add the example notebook to the book by giving it an entry in the table of contents in ","position":{"start":{"line":124,"column":1},"end":{"line":124,"column":1}},"key":"bf7asV1x7D"},{"type":"inlineCode","value":"myst.yml","position":{"start":{"line":124,"column":1},"end":{"line":124,"column":1}},"key":"xK6Zl4uXII"},{"type":"text","value":".\nRebuild the book and look at the new page.","position":{"start":{"line":124,"column":1},"end":{"line":124,"column":1}},"key":"hyNkbdD5dS"}],"key":"cY9vLxFcP9"}],"enumerated":true,"label":"exercise-l75XkfOucE","identifier":"exercise-l75xkfouce","enumerator":"1","html_id":"exercise-l75xkfouce","key":"ynDaqHK7O6"},{"type":"exercise","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Make changes","position":{"start":{"line":128,"column":1},"end":{"line":128,"column":1}},"key":"aDqaAzMfZN"}],"key":"D0Lzg8Mzyg"},{"type":"paragraph","position":{"start":{"line":129,"column":1},"end":{"line":131,"column":1}},"children":[{"type":"text","value":"Navigate to ","position":{"start":{"line":129,"column":1},"end":{"line":129,"column":1}},"key":"PlzjRyJdvv"},{"type":"link","url":"http://locahost:8888","position":{"start":{"line":129,"column":1},"end":{"line":129,"column":1}},"children":[{"type":"text","value":"your Jupyter Lab instance","position":{"start":{"line":129,"column":1},"end":{"line":129,"column":1}},"key":"n8nspzxDhB"}],"urlSource":"http://locahost:8888","key":"nMf19QgmZ4"},{"type":"text","value":".\nMake some changes to the notebook.\nTry adding,","position":{"start":{"line":129,"column":1},"end":{"line":129,"column":1}},"key":"vNQ73nEaIx"}],"key":"BrIGvvZPrX"},{"type":"list","ordered":true,"start":1,"spread":false,"position":{"start":{"line":133,"column":1},"end":{"line":135,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":133,"column":1},"end":{"line":133,"column":1}},"children":[{"type":"paragraph","children":[{"type":"text","value":"Markdown cells","position":{"start":{"line":133,"column":1},"end":{"line":133,"column":1}},"key":"oysh8yRTEi"}],"key":"RexvAHWEpZ"}],"key":"MNUGeCRzUZ"},{"type":"listItem","spread":true,"position":{"start":{"line":134,"column":1},"end":{"line":135,"column":1}},"children":[{"type":"paragraph","children":[{"type":"text","value":"Code cells in Python","position":{"start":{"line":134,"column":1},"end":{"line":134,"column":1}},"key":"zJAoKeJuty"}],"key":"syMjgH1vXR"}],"key":"eoMYFxqSU4"}],"key":"vQwEf0IZbd"},{"type":"paragraph","position":{"start":{"line":136,"column":1},"end":{"line":137,"column":1}},"children":[{"type":"text","value":"Rerun the entire notebook by clicking “Run” -> “Restart Kernel and Run All Cells…”\nRebuild the book and look at your changes.","position":{"start":{"line":136,"column":1},"end":{"line":136,"column":1}},"key":"fz2nIfLDFm"}],"key":"kDkgkTSNmM"}],"enumerated":true,"label":"exercise-dFtecayJsm","identifier":"exercise-dftecayjsm","enumerator":"2","html_id":"exercise-dftecayjsm","key":"eOl2SjRYC3"},{"type":"exercise","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Execute at build time","position":{"start":{"line":140,"column":1},"end":{"line":140,"column":1}},"key":"JFaNY7jcEe"}],"key":"yN2I3xEAvS"},{"type":"paragraph","position":{"start":{"line":141,"column":1},"end":{"line":142,"column":1}},"children":[{"type":"text","value":"Instead of running the notebook in Jupyter Lab, you can also execute the notebook as the book is built.\nTo do this, run,","position":{"start":{"line":141,"column":1},"end":{"line":141,"column":1}},"key":"uwuGrkqaRK"}],"key":"usPvcmYXsx"},{"type":"code","lang":"console","value":"myst start --execute","position":{"start":{"line":144,"column":1},"end":{"line":146,"column":1}},"key":"sU56Yb8fVR"},{"type":"admonition","kind":"hint","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Hint","key":"CNix49Tvqi"}],"key":"qOlySHGdam"},{"type":"paragraph","position":{"start":{"line":149,"column":1},"end":{"line":149,"column":1}},"children":[{"type":"text","value":"If you installed Jupyter in a virtual environment, like we recommended above, you will need to run myst in that environment so that a Jupyter server can be launched.","position":{"start":{"line":149,"column":1},"end":{"line":149,"column":1}},"key":"irrutsZc8e"}],"key":"n2gUMs4Whs"},{"type":"code","lang":"console","value":"source ./venv/bin/activate\nmyst start --execute","position":{"start":{"line":151,"column":1},"end":{"line":154,"column":1}},"key":"j35Kyrv3Om"}],"key":"Vlpz6x1EEz"},{"type":"paragraph","position":{"start":{"line":157,"column":1},"end":{"line":158,"column":1}},"children":[{"type":"text","value":"Now, make changes to the notebook and save it ","position":{"start":{"line":157,"column":1},"end":{"line":157,"column":1}},"key":"nmrXM8nSto"},{"type":"strong","position":{"start":{"line":157,"column":1},"end":{"line":157,"column":1}},"children":[{"type":"text","value":"without","position":{"start":{"line":157,"column":1},"end":{"line":157,"column":1}},"key":"xKgUQaZIzX"}],"key":"zcwrrZwz6f"},{"type":"text","value":" running the cells.\nYou will see MyST detect the notebook has been changed and re-run it automatically.","position":{"start":{"line":157,"column":1},"end":{"line":157,"column":1}},"key":"a50gOP1CJS"}],"key":"efqgjiaKwO"}],"enumerated":true,"label":"exercise-tBwWJsWnOW","identifier":"exercise-tbwwjswnow","enumerator":"3","html_id":"exercise-tbwwjswnow","key":"rSmIHL7Fbg"},{"type":"heading","depth":2,"position":{"start":{"line":162,"column":1},"end":{"line":162,"column":1}},"children":[{"type":"text","value":"Executable Markdown","position":{"start":{"line":162,"column":1},"end":{"line":162,"column":1}},"key":"Qame9M44gX"}],"label":"lesson-exec-markdown","identifier":"lesson-exec-markdown","html_id":"lesson-exec-markdown","key":"v7GBNLHFW5"},{"type":"paragraph","position":{"start":{"line":164,"column":1},"end":{"line":167,"column":1}},"children":[{"type":"text","value":"Unlike Jupyter notebook files, Markdown files do not store the output of executions.\nThis means to include the outputs in our project, we must execute the cells at build time.\nTo make a Markdown file executable, you must first add a ","position":{"start":{"line":164,"column":1},"end":{"line":164,"column":1}},"key":"xuB9wqStgt"},{"type":"inlineCode","value":"kernelspec","position":{"start":{"line":164,"column":1},"end":{"line":164,"column":1}},"key":"XUb1JpNKnV"},{"type":"text","value":" to the files ","position":{"start":{"line":164,"column":1},"end":{"line":164,"column":1}},"key":"KEgginhs9V"},{"type":"link","url":"https://mystmd.org/guide/frontmatter","position":{"start":{"line":164,"column":1},"end":{"line":164,"column":1}},"children":[{"type":"text","value":"frontmatter","position":{"start":{"line":164,"column":1},"end":{"line":164,"column":1}},"key":"ERUxJ1SYUm"}],"urlSource":"xref:myst-guide/frontmatter","dataUrl":"https://mystmd.org/guide/frontmatter.json","internal":false,"protocol":"xref:myst","key":"pwloIo9h8R"},{"type":"text","value":".\nFor example, in this page,","position":{"start":{"line":164,"column":1},"end":{"line":164,"column":1}},"key":"uy9loltuvk"}],"key":"RRqEUmgmDB"},{"type":"code","lang":"yaml","value":"---\nkernelspec:\n    name: python3\n    display_name: 'Python 3'\n---","position":{"start":{"line":169,"column":1},"end":{"line":175,"column":1}},"key":"sfgkoGUiQT"},{"type":"admonition","kind":"tip","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Tip","key":"jwtZwJx36M"}],"key":"GotP2p3V8F"},{"type":"paragraph","position":{"start":{"line":178,"column":1},"end":{"line":178,"column":1}},"children":[{"type":"text","value":"The MyST Guide has a section on ","position":{"start":{"line":178,"column":1},"end":{"line":178,"column":1}},"key":"YNTR2ZSvY8"},{"type":"link","url":"https://mystmd.org/guide/md-vs-ipynb","position":{"start":{"line":178,"column":1},"end":{"line":178,"column":1}},"children":[{"type":"text","value":"the advantages of the ","position":{"start":{"line":178,"column":1},"end":{"line":178,"column":1}},"key":"KhATyIxkic"},{"type":"inlineCode","value":".md","position":{"start":{"line":178,"column":1},"end":{"line":178,"column":1}},"key":"EC4RZ4AX0n"},{"type":"text","value":" and ","position":{"start":{"line":178,"column":1},"end":{"line":178,"column":1}},"key":"DRqns7qsxu"},{"type":"inlineCode","value":".ipynb","position":{"start":{"line":178,"column":1},"end":{"line":178,"column":1}},"key":"MzZSggvWLh"},{"type":"text","value":" formats","position":{"start":{"line":178,"column":1},"end":{"line":178,"column":1}},"key":"Ho9SGHqhun"}],"urlSource":"xref:myst-guide/md-vs-ipynb","dataUrl":"https://mystmd.org/guide/md-vs-ipynb.json","internal":false,"protocol":"xref:myst","key":"NhX1Hmd5dw"},{"type":"text","value":".","position":{"start":{"line":178,"column":1},"end":{"line":178,"column":1}},"key":"C4yuc1n7hF"}],"key":"NkzYxcNBiX"}],"key":"Mfi3hS3G5Y"},{"type":"paragraph","position":{"start":{"line":181,"column":1},"end":{"line":182,"column":1}},"children":[{"type":"text","value":"You can add a block of executable code using the ","position":{"start":{"line":181,"column":1},"end":{"line":181,"column":1}},"key":"SFGlOsTWjx"},{"type":"crossReference","url":"/notebooks-with-markdown","position":{"start":{"line":181,"column":1},"end":{"line":181,"column":1}},"children":[{"type":"inlineCode","value":"code-cell","position":{"start":{"line":181,"column":1},"end":{"line":181,"column":1}},"key":"eh4HzHyevE"},{"type":"text","value":" directive","position":{"start":{"line":181,"column":1},"end":{"line":181,"column":1}},"key":"lmDasWuupL"}],"urlSource":"xref:myst-guide/notebooks-with-markdown#code-cell","remote":true,"remoteBaseUrl":"https://mystmd.org/guide","dataUrl":"/notebooks-with-markdown.json","identifier":"code-cell","label":"code-cell","html_id":"code-cell","protocol":"xref:myst","template":"{name}","resolved":true,"key":"k4OZRFkNUL"},{"type":"text","value":".\nThe directive has the format,","position":{"start":{"line":181,"column":1},"end":{"line":181,"column":1}},"key":"KS32IDcnWI"}],"key":"tW40wUV2JN"},{"type":"code","lang":"markdown","value":":::{code-cell} <language>\n:key: value\n<code>\n:::","position":{"start":{"line":184,"column":1},"end":{"line":189,"column":1}},"key":"z3yiCfM62P"},{"type":"paragraph","position":{"start":{"line":191,"column":1},"end":{"line":191,"column":1}},"children":[{"type":"text","value":"The key/value pairs allow you to tag the cell in the same way as ","position":{"start":{"line":191,"column":1},"end":{"line":191,"column":1}},"key":"XGOrMjjIjH"},{"type":"crossReference","position":{"start":{"line":191,"column":1},"end":{"line":191,"column":1}},"children":[{"type":"text","value":"with ","position":{"start":{"line":191,"column":1},"end":{"line":191,"column":1}},"key":"V93lJZE47U"},{"type":"inlineCode","value":"ipynb","position":{"start":{"line":191,"column":1},"end":{"line":191,"column":1}},"key":"MkmtS2Gp2A"}],"identifier":"label-notebooks","label":"label-notebooks","kind":"paragraph","template":"Paragraph","resolved":true,"html_id":"label-notebooks","key":"HsQDKgiCa0"},{"type":"text","value":".","position":{"start":{"line":191,"column":1},"end":{"line":191,"column":1}},"key":"Yct31IarHI"}],"key":"w68YhOsnRb"},{"type":"exercise","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Code cells","position":{"start":{"line":193,"column":1},"end":{"line":193,"column":1}},"key":"SHUoJrcYaP"}],"key":"LZHI25WFBq"},{"type":"admonition","kind":"note","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Note","key":"RALtQWF5yB"}],"key":"gT2kmk1p4m"},{"type":"paragraph","position":{"start":{"line":195,"column":1},"end":{"line":196,"column":1}},"children":[{"type":"text","value":"We will use the default Python kernel in these examples.\nHowever, you can use another kernel, such as Javascript, R or Julia ","position":{"start":{"line":195,"column":1},"end":{"line":195,"column":1}},"key":"Evrk1hGEyW"},{"type":"crossReference","url":"/notebooks-with-markdown","position":{"start":{"line":195,"column":1},"end":{"line":195,"column":1}},"children":[{"type":"text","value":"by changing the page frontmatter and updating code cell blocks","position":{"start":{"line":195,"column":1},"end":{"line":195,"column":1}},"key":"PAgN38fpBO"}],"urlSource":"xref:myst-guide/notebooks-with-markdown#use-a-different-kernel","remote":true,"remoteBaseUrl":"https://mystmd.org/guide","dataUrl":"/notebooks-with-markdown.json","identifier":"use-a-different-kernel","label":"use-a-different-kernel","html_id":"use-a-different-kernel","protocol":"xref:myst","template":"{name}","resolved":true,"key":"oC7QQwkk4A"},{"type":"text","value":".","position":{"start":{"line":195,"column":1},"end":{"line":195,"column":1}},"key":"d5p8L5qAXb"}],"key":"yOI3tOZdvs"}],"key":"htXOR9NaDG"},{"type":"paragraph","position":{"start":{"line":199,"column":1},"end":{"line":199,"column":1}},"children":[{"type":"text","value":"Put the following Python snippet in a code cell.","position":{"start":{"line":199,"column":1},"end":{"line":199,"column":1}},"key":"peBfn2mfS0"}],"key":"Z74gS6TwOj"},{"type":"code","lang":"python","value":"def fib(n):\n    if n < 0:\n        return\n    if n in [0, 1]:\n        return n\n    else:\n        return fib(n-2) + fib(n-1)\n\n\nfor i in range(10):\n    print(i, fib(i))","position":{"start":{"line":201,"column":1},"end":{"line":213,"column":1}},"key":"N3DxAt9xbU"},{"type":"paragraph","position":{"start":{"line":215,"column":1},"end":{"line":215,"column":1}},"children":[{"type":"text","value":"Rebuild the book (with the ","position":{"start":{"line":215,"column":1},"end":{"line":215,"column":1}},"key":"n8ZrtUBAo2"},{"type":"inlineCode","value":"--execute","position":{"start":{"line":215,"column":1},"end":{"line":215,"column":1}},"key":"jsoAVraDN7"},{"type":"text","value":" flag) and look at the result.","position":{"start":{"line":215,"column":1},"end":{"line":215,"column":1}},"key":"JXOm7VYGtP"}],"key":"Kump7F38Ws"},{"type":"paragraph","position":{"start":{"line":217,"column":1},"end":{"line":218,"column":1}},"children":[{"type":"text","value":"Now, add a ","position":{"start":{"line":217,"column":1},"end":{"line":217,"column":1}},"key":"p3ftrHTpwO"},{"type":"inlineCode","value":"label","position":{"start":{"line":217,"column":1},"end":{"line":217,"column":1}},"key":"BEzDRPy3ml"},{"type":"text","value":" (using the key/value notation) to the code cell and reference it ","position":{"start":{"line":217,"column":1},"end":{"line":217,"column":1}},"key":"flSQVkpaYn"},{"type":"link","url":"x","position":{"start":{"line":217,"column":1},"end":{"line":217,"column":1}},"children":[{"type":"text","value":"here","position":{"start":{"line":217,"column":1},"end":{"line":217,"column":1}},"key":"LOlP8ndhty"}],"urlSource":"x","key":"OldUPCXJAM"},{"type":"text","value":".\nMake the code cell a figure by adding a ","position":{"start":{"line":217,"column":1},"end":{"line":217,"column":1}},"key":"C8VsTxZDI8"},{"type":"inlineCode","value":"caption","position":{"start":{"line":217,"column":1},"end":{"line":217,"column":1}},"key":"SOkGTVIbTK"},{"type":"text","value":"; notice how the reference changes.","position":{"start":{"line":217,"column":1},"end":{"line":217,"column":1}},"key":"U7Ck8rsI5k"}],"key":"Xi9lEeFtPD"}],"enumerated":true,"label":"exercise-gQwWoEf2Ar","identifier":"exercise-gqwwoef2ar","enumerator":"4","html_id":"exercise-gqwwoef2ar","key":"Jt7EltjOwo"},{"type":"paragraph","position":{"start":{"line":221,"column":1},"end":{"line":221,"column":1}},"children":[{"type":"text","value":"You can also use the ","position":{"start":{"line":221,"column":1},"end":{"line":221,"column":1}},"key":"nw2eKrO5xb"},{"type":"crossReference","url":"/notebooks-with-markdown","position":{"start":{"line":221,"column":1},"end":{"line":221,"column":1}},"children":[{"type":"inlineCode","value":"eval","position":{"start":{"line":221,"column":1},"end":{"line":221,"column":1}},"key":"Of9eDDqcGi"},{"type":"text","value":" role","position":{"start":{"line":221,"column":1},"end":{"line":221,"column":1}},"key":"Vo9oYeEHzU"}],"urlSource":"xref:myst-guide/notebooks-with-markdown#myst-inline-expressions","remote":true,"remoteBaseUrl":"https://mystmd.org/guide","dataUrl":"/notebooks-with-markdown.json","identifier":"myst:inline-expressions","label":"myst:inline-expressions","html_id":"myst-inline-expressions","protocol":"xref:myst","template":"{name}","resolved":true,"key":"hfSvOxATpo"},{"type":"text","value":" to execute expressions in Markdown text.","position":{"start":{"line":221,"column":1},"end":{"line":221,"column":1}},"key":"i6zI7H3jZy"}],"key":"ZyxueSFhIi"},{"type":"exercise","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Inline execution","position":{"start":{"line":223,"column":1},"end":{"line":223,"column":1}},"key":"frI3wqUaOi"}],"key":"wXS6aL2z2e"},{"type":"paragraph","position":{"start":{"line":224,"column":1},"end":{"line":224,"column":1}},"children":[{"type":"text","value":"Copy the following examples using the ","position":{"start":{"line":224,"column":1},"end":{"line":224,"column":1}},"key":"b0dPbaB2Kf"},{"type":"inlineCode","value":"eval","position":{"start":{"line":224,"column":1},"end":{"line":224,"column":1}},"key":"VJaURiXyse"},{"type":"text","value":" role and complete the statements to execute.","position":{"start":{"line":224,"column":1},"end":{"line":224,"column":1}},"key":"qRnUqez7ek"}],"key":"oOFlbPz6Pn"},{"type":"code","lang":"markdown","value":"$6872 \\times 3409$ is {eval}``\n\nThe first 15 multiples of 23 are {eval}``","position":{"start":{"line":226,"column":1},"end":{"line":230,"column":1}},"key":"cRx1pZIufZ"},{"type":"admonition","kind":"hint","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Hint","key":"u8SXn34836"}],"key":"lJoStogu7V"},{"type":"paragraph","position":{"start":{"line":233,"column":1},"end":{"line":233,"column":1}},"children":[{"type":"text","value":"For the second example, you may want to use a ","position":{"start":{"line":233,"column":1},"end":{"line":233,"column":1}},"key":"P04Q95WvEv"},{"type":"link","url":"https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions","position":{"start":{"line":233,"column":1},"end":{"line":233,"column":1}},"children":[{"type":"text","value":"list comprehension","position":{"start":{"line":233,"column":1},"end":{"line":233,"column":1}},"key":"vtoVooHsbe"}],"urlSource":"https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions","key":"Y1ZVBruM0K"},{"type":"text","value":".","position":{"start":{"line":233,"column":1},"end":{"line":233,"column":1}},"key":"cNSVokA7rF"}],"key":"vvjLdIlEoW"}],"key":"KBUSPETPvx"}],"enumerated":true,"label":"exercise-MhSn85MhCO","identifier":"exercise-mhsn85mhco","enumerator":"5","html_id":"exercise-mhsn85mhco","key":"q4kgBfQlZu"},{"type":"heading","depth":2,"position":{"start":{"line":237,"column":1},"end":{"line":237,"column":1}},"children":[{"type":"text","value":"Cell Tags and Hiding Input","position":{"start":{"line":237,"column":1},"end":{"line":237,"column":1}},"key":"fhJexZ1ZVG"}],"identifier":"cell-tags-and-hiding-input","label":"Cell Tags and Hiding Input","html_id":"cell-tags-and-hiding-input","implicit":true,"key":"n58aPQjFTy"},{"type":"paragraph","position":{"start":{"line":239,"column":1},"end":{"line":241,"column":1}},"children":[{"type":"crossReference","url":"/notebook-configuration","position":{"start":{"line":239,"column":1},"end":{"line":239,"column":1}},"children":[{"type":"text","value":"Cell tags","position":{"start":{"line":239,"column":1},"end":{"line":239,"column":1}},"key":"FcAd7CIIJ9"}],"urlSource":"xref:myst-guide/notebook-configuration#notebook-cell-tags","remote":true,"remoteBaseUrl":"https://mystmd.org/guide","dataUrl":"/notebook-configuration.json","identifier":"notebook-cell-tags","label":"notebook-cell-tags","html_id":"notebook-cell-tags","protocol":"xref:myst","template":"{name}","resolved":true,"key":"DOAt3eJ94s"},{"type":"text","value":" in Jupyter Notebooks are metadata labels that you can assign to individual cells.\nThey are useful for customizing the behavior of cells, such as hiding code input.\nMarkdown cells allow you to add tags as well, e.g. ","position":{"start":{"line":239,"column":1},"end":{"line":239,"column":1}},"key":"SbRUVaLYwp"},{"type":"inlineCode","value":":tags: [hide-input]","position":{"start":{"line":239,"column":1},"end":{"line":239,"column":1}},"key":"W7BRUyfLxe"},{"type":"text","value":".","position":{"start":{"line":239,"column":1},"end":{"line":239,"column":1}},"key":"WFYammyJR7"}],"key":"B5qdDEXzC9"},{"type":"paragraph","position":{"start":{"line":243,"column":1},"end":{"line":244,"column":1}},"children":[{"type":"text","value":"To hide the input of a code cell (so only the output is visible), you can add a tag like ","position":{"start":{"line":243,"column":1},"end":{"line":243,"column":1}},"key":"V0SySAReNb"},{"type":"inlineCode","value":"hide_input","position":{"start":{"line":243,"column":1},"end":{"line":243,"column":1}},"key":"OZd9nULsE2"},{"type":"text","value":" to that cell.\n","key":"JTDokTk0RY"},{"type":"abbreviation","title":"Jupyter Book 2","children":[{"type":"text","value":"JB2","key":"iH4RHVxgN6"}],"key":"BCIpJaa19k"},{"type":"text","value":" recognizes this tag and will hide the code input when rendering or exporting the notebook.","key":"pFYPNlUchM"}],"key":"cuJxXGIg31"},{"type":"paragraph","position":{"start":{"line":246,"column":1},"end":{"line":246,"column":1}},"children":[{"type":"text","value":"To add a tag:","position":{"start":{"line":246,"column":1},"end":{"line":246,"column":1}},"key":"PSFZePNbZW"}],"key":"FzH22LNtlH"},{"type":"list","ordered":true,"start":1,"spread":false,"position":{"start":{"line":248,"column":1},"end":{"line":251,"column":1}},"children":[{"type":"listItem","spread":true,"position":{"start":{"line":248,"column":1},"end":{"line":248,"column":1}},"children":[{"type":"paragraph","children":[{"type":"text","value":"Select the cell.","position":{"start":{"line":248,"column":1},"end":{"line":248,"column":1}},"key":"w5bgLWpVdG"}],"key":"I0BUP0TUGE"}],"key":"MwcdsO5AWy"},{"type":"listItem","spread":true,"position":{"start":{"line":249,"column":1},"end":{"line":249,"column":1}},"children":[{"type":"paragraph","children":[{"type":"text","value":"Open the “View” menu and enable the “Cell Toolbar” → “Tags”.","position":{"start":{"line":249,"column":1},"end":{"line":249,"column":1}},"key":"fF29GglyGo"}],"key":"mSSqT9aNNy"}],"key":"qcJbBKZwIk"},{"type":"listItem","spread":true,"position":{"start":{"line":250,"column":1},"end":{"line":251,"column":1}},"children":[{"type":"paragraph","children":[{"type":"text","value":"Add the tag ","position":{"start":{"line":250,"column":1},"end":{"line":250,"column":1}},"key":"SP2JDKkyqY"},{"type":"inlineCode","value":"hide_input","position":{"start":{"line":250,"column":1},"end":{"line":250,"column":1}},"key":"mDI7eDm0Ci"},{"type":"text","value":" (or another tag recognized by your toolchain).","position":{"start":{"line":250,"column":1},"end":{"line":250,"column":1}},"key":"SY0BwNdaWO"}],"key":"qvTpbtYVt1"}],"key":"EHzV5abTcg"}],"key":"ewJnGgetng"},{"type":"paragraph","position":{"start":{"line":252,"column":1},"end":{"line":252,"column":1}},"children":[{"type":"text","value":"This feature is especially useful for creating clean, reader-friendly notebooks where you want to focus on results rather than code details, see below.","position":{"start":{"line":252,"column":1},"end":{"line":252,"column":1}},"key":"a4R3Hxoltu"}],"key":"rfGxu0jDPM"}],"key":"GncHDW0AxO"},{"type":"block","kind":"notebook-code","children":[{"type":"code","lang":"python","executable":true,"value":"print(\"This is the output of the cell, but the input code is hidden.\")","visibility":"hide","key":"MwhvCccmXR"},{"type":"outputs","id":"NU5f3_aD2Il1oZmooOfp-","children":[],"visibility":"show","key":"cd8WB116TS"}],"data":{"tags":[]},"visibility":"show","key":"FkVHtIKkuM"},{"type":"block","children":[{"type":"exercise","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"Remove input","position":{"start":{"line":261,"column":1},"end":{"line":261,"column":1}},"key":"FsmJdktL2M"}],"key":"WyZl64OIYG"},{"type":"paragraph","position":{"start":{"line":262,"column":1},"end":{"line":263,"column":1}},"children":[{"type":"text","value":"Create a code cell that calculates the square of numbers from 5 to 8 and prints the results.\nRemove the input code from being displayed by adding the appropriate tag.","position":{"start":{"line":262,"column":1},"end":{"line":262,"column":1}},"key":"MYZDuA1ID3"}],"key":"R7xszPI9TW"}],"enumerated":true,"label":"exercise-H3nGlvbqrA","identifier":"exercise-h3nglvbqra","enumerator":"6","html_id":"exercise-h3nglvbqra","key":"y4GehR6XC2"},{"type":"heading","depth":2,"position":{"start":{"line":267,"column":1},"end":{"line":267,"column":1}},"children":[{"type":"text","value":"GitHub Actions Example","position":{"start":{"line":267,"column":1},"end":{"line":267,"column":1}},"key":"E8O4SNnl6L"}],"label":"GHA-example","identifier":"gha-example","html_id":"gha-example","key":"d5YOhHZww8"},{"type":"paragraph","position":{"start":{"line":269,"column":1},"end":{"line":269,"column":1}},"children":[{"type":"text","value":"Here is an example GitHub Action workflow file to illustrate one possible way to build a virtual environment and execute notebooks during the book build. We will cover other aspects of the workflow file in later lessons (for example, ","key":"DB4wkuASho"},{"type":"abbreviation","title":"GitHub","children":[{"type":"text","value":"GH","key":"DkJK3sl0WV"}],"key":"pC4jZWqkyO"},{"type":"text","value":" Actions itself and PDF generation).","key":"DpFHNOg4HC"}],"key":"eEvbXOEXAk"},{"type":"admonition","kind":"tip","children":[{"type":"admonitionTitle","children":[{"type":"text","value":"GitHub Action workflow example","position":{"start":{"line":271,"column":1},"end":{"line":271,"column":1}},"key":"xNzo03XCWf"}],"key":"bjLaNEpZQ9"},{"type":"code","lang":"yaml","value":"name: MyST GitHub Pages Deploy\non:\n  push:\n    branches: [main]\nenv:\n  # `BASE_URL` determines the website is served from, including CSS & JS assets\n  # You may need to change this to `BASE_URL: ''`\n  BASE_URL: /${{ github.event.repository.name }}\n\n# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages\npermissions:\n  contents: read\n  pages: write\n  id-token: write\n\nconcurrency:\n  group: 'pages'\n  cancel-in-progress: false\njobs:\n  deploy:\n    environment:\n      name: github-pages\n      url: ${{ steps.deployment.outputs.page_url }}\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - name: Setup Pages\n        uses: actions/configure-pages@v3\n      - uses: actions/setup-node@v4\n        with:\n          node-version: 18.x\n      - uses: typst-community/setup-typst@v4\n\n    # Install Python and dependencies\n      - name: Set up Python\n        uses: actions/setup-python@v5\n        with:\n          python-version: '3.11'   # or your version\n\n      - name: Install Python dependencies\n        run: |\n          python -m pip install --upgrade pip\n          if [ -f requirements.txt ]; then pip install -r requirements.txt; fi\n          pip install jupyter-server nbclient nbformat ipykernel jupyter-client\n          # pip install plotly kaleido          \n          python -m ipykernel install --user --name=python3\n          \n    # Install MyST \n      - name: Install MyST Markdown\n        run: npm install -g mystmd\n      \n    # Build PDF\n      - name: Build PDF\n        run: |\n          myst build --pdf\n\n      - name: Upload Output PDF as Artifact\n        uses: actions/upload-artifact@v4\n        with:\n          name: Output PDF\n          path: exports/book.pdf\n          compression-level: 0\n    \n          # Build book\n      - name: Build execute \n        run: myst build --execute --html\n\n      - name: Upload artifact\n        uses: actions/upload-pages-artifact@v3\n        with:\n          path: './_build/html'\n          \n      - name: Deploy to GitHub Pages\n        id: deployment\n        uses: actions/deploy-pages@v4","key":"rdJxOtNPLL"}],"class":"dropdown","key":"jnt2cgzDP7"}],"key":"xcj9UKKH3h"}],"key":"w9HLqU1xJd"},"references":{"cite":{"order":[],"data":{}}},"footer":{"navigation":{"prev":{"title":"Reusing and sharing content","url":"/reuse","group":"Jupyter Book 2 Workshop Template"},"next":{"title":"Build online with GitHub","url":"/workflows","group":"Jupyter Book 2 Workshop Template"}}},"domain":"http://localhost:3000"}