### Install and Build Extension Source: https://github.com/mwouts/jupytext/blob/main/jupyterlab/packages/jupyterlab-jupytext-extension/ui-tests/README.md Commands to install dependencies and build the extension in production mode. Ensure the extension is installed in JupyterLab before proceeding. ```sh jlpm install jlpm build:prod ``` -------------------------------- ### Develop Jupytext Extension: Setup and Build Source: https://github.com/mwouts/jupytext/blob/main/jupyterlab/packages/jupyterlab-jupytext-extension/README.md Commands to set up a development environment for the jupyterlab-jupytext extension. This includes installing development dependencies, linking the extension, and starting a watch process. ```bash pip install -e '.[dev]' cd jupyterlab/packages/jupyterlab-jupytext-extension jlpm jlpm install:extension # Symlink into {sys.prefix}/share/jupyter/labextensions ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/mwouts/jupytext/blob/main/docs/developing.md Installs the pre-commit framework, which automatically runs code formatting and linting checks before each commit. ```bash pre-commit install ``` -------------------------------- ### Install Calysto Scheme Source: https://github.com/mwouts/jupytext/blob/main/tests/data/notebooks/outputs/ipynb_to_md/Reference Guide for Calysto Scheme.md Install Calysto Scheme using pip3. The `--user` flag installs it for the current user, while system-wide installation requires sudo. ```bash pip3 install --upgrade calysto-scheme --user -U python3 -m calysto_kernel install --user ``` ```bash sudo pip3 install --upgrade calysto-scheme -U sudo python3 -m calysto_kernel install ``` -------------------------------- ### Perform Addition in Python Source: https://github.com/mwouts/jupytext/blob/main/tests/data/notebooks/inputs/ipynb_py/jupyter.ipynb Demonstrates basic variable assignment and addition. Ensure Python is installed and the environment is set up for execution. ```python a = 1 b = 2 a + b ``` -------------------------------- ### Install UI Test Dependencies Source: https://github.com/mwouts/jupytext/blob/main/jupyterlab/packages/jupyterlab-jupytext-extension/ui-tests/README.md Commands to install the necessary dependencies for UI testing, including Playwright browser binaries. This is typically needed only once. ```sh cd ./ui-tests jlpm install jlpm playwright install cd .. ``` -------------------------------- ### Print Hello World in Wolfram Language Source: https://github.com/mwouts/jupytext/blob/main/tests/data/notebooks/inputs/ipynb_wolfram/wolfram.ipynb Use Print to display simple text output. This is a basic starting point for any Wolfram Language script. ```wolfram Print["Hello, World!"]; ``` -------------------------------- ### C++11 Constructors Example Source: https://github.com/mwouts/jupytext/blob/main/tests/data/notebooks/inputs/ipynb_cpp/xcpp_by_quantstack.ipynb Demonstrates C++11 constructors (default, copy, and move) for a class 'Foo11'. ```cpp class Foo11 { public: Foo11() { std::cout << "Foo11 default constructor" << std::endl; } Foo11(const Foo11&) { std::cout << "Foo11 copy constructor" << std::endl; } Foo11(Foo11&&) { std::cout << "Foo11 move constructor" << std::endl; } }; ``` ```cpp Foo11 f1; Foo11 f2(f1); Foo11 f3(std::move(f1)); ``` -------------------------------- ### Install ThreadJob Module Source: https://github.com/mwouts/jupytext/blob/main/tests/data/notebooks/outputs/script_to_ipynb/build.ipynb Checks if the ThreadJob module is available and installs version 1.1.2 for the current user if it is not found. ```powershell # Install ThreadJob if not available $threadJob = Get-Module ThreadJob -ListAvailable if ($null -eq $threadjob) { Install-Module ThreadJob -RequiredVersion 1.1.2 -Scope CurrentUser -Force } ``` -------------------------------- ### Install Node.js with Conda Source: https://github.com/mwouts/jupytext/blob/main/docs/developing.md Installs Node.js version 20 or higher using Conda, a prerequisite for some Jupytext development installations. ```bash conda install 'nodejs>=20' -c conda-forge ``` -------------------------------- ### Commented-out Example (Modulo) Source: https://github.com/mwouts/jupytext/blob/main/tests/data/notebooks/inputs/ipynb_coconut/coconut_homepage_demo.ipynb A commented-out example showing the modulo operation, likely intended as a placeholder or for future use. ```coconut # 5 `mod` 3 == 2 ``` -------------------------------- ### Initialize Stata Kernel Source: https://github.com/mwouts/jupytext/blob/main/tests/data/notebooks/outputs/ipynb_to_md/stata_notebook.md This comment indicates the use of the stata_kernel for running Stata code in a Jupyter Notebook. Ensure the stata_kernel is installed. ```stata // This notebook uses the stata_kernel: https://github.com/kylebarron/stata_kernel ``` -------------------------------- ### Install Jupytext Notebook Extension Source: https://github.com/mwouts/jupytext/blob/main/docs/install.md Install and enable the Jupytext nbextension for classic Jupyter Notebook (versions 6.x and below). Use [--user] for user-specific installation. ```bash jupyter nbextension install --py jupytext [--user] ``` ```bash jupyter nbextension enable --py jupytext [--user] ``` -------------------------------- ### Percent Format Notebook Example Source: https://github.com/mwouts/jupytext/blob/main/README.md This is an example of a Python notebook in the `py:percent` format, which uses a `.py` extension. It's suitable for version control and editing in IDEs. ```python # %% [markdown] # This is a markdown cell # %% def f(x): return 3*x+1 ``` -------------------------------- ### Commented-out Example (Pattern Matching on Tuples) Source: https://github.com/mwouts/jupytext/blob/main/tests/data/notebooks/inputs/ipynb_coconut/coconut_homepage_demo.ipynb A commented-out example showing pattern matching on a tuple, likely for extracting elements from a sequence. ```coconut # (| first_elem() |) :: rest_elems() ``` -------------------------------- ### Example jupytext-config Session Source: https://github.com/mwouts/jupytext/blob/main/docs/text-notebooks.md Demonstrates a typical workflow for managing default viewers using the `jupytext-config` command-line tool, including setting, inspecting, and unsetting viewers. ```bash # starting from the default config of JupyterLab $ jupytext-config list-default-viewer # we add the default viewer for 2 doctypes $ jupytext-config set-default-viewer python markdown # we check what was done $ jupytext-config list-default-viewer python: Jupytext Notebook markdown: Jupytext Notebook # we can now remove the default viewer for markdown $ jupytext-config unset-default-viewer markdown # and check again $ jupytext-config list-default-viewer python: Jupytext Notebook $ ``` -------------------------------- ### Commented-out Example (Function Composition) Source: https://github.com/mwouts/jupytext/blob/main/tests/data/notebooks/inputs/ipynb_coconut/coconut_homepage_demo.ipynb A commented-out example illustrating function composition, likely for demonstrating a more advanced functional concept. ```coconut # (f..g..h)(x, y, z) ``` -------------------------------- ### Install Development Version from GitHub Source: https://github.com/mwouts/jupytext/blob/main/docs/developing.md Use this command to install a development version of Jupytext directly from its GitHub repository. Requires Node.js. ```bash HATCH_BUILD_HOOKS_ENABLE=true pip install git+https://github.com/mwouts/jupytext.git ``` -------------------------------- ### Multiple Format Specifications (jupytext.toml - Tutorials) Source: https://github.com/mwouts/jupytext/blob/main/docs/config.md Define multiple pairing configurations in jupytext.toml. This example pairs tutorial notebooks to markdown and Python scripts, while other notebooks pair only to Python scripts. ```toml # jupytext.toml # Tutorial notebooks get paired to markdown docs [[formats]] "notebooks/tutorials/" = "ipynb" "docs/tutorials/" = "md" "scripts/tutorials/" = "py:percent" # Default pairing: all other notebooks are paired with Python scripts [[formats]] "notebooks/" = "ipynb" "scripts/" = "py:percent" ``` -------------------------------- ### Print Hello World in Python Source: https://github.com/mwouts/jupytext/blob/main/tests/data/notebooks/outputs/ipynb_to_md/raw_cell_with_non_dict_yaml_content.md A basic Python code snippet to print 'Hello, World!' to the console. This is often used as a first example. ```python print("Hello, World!") ``` -------------------------------- ### Install Jupytext with Pip Source: https://github.com/mwouts/jupytext/blob/main/README.md Install Jupytext in your Python environment using pip. ```bash pip install jupytext ``` -------------------------------- ### Start JupyterLab Server for Test Generation Source: https://github.com/mwouts/jupytext/blob/main/jupyterlab/packages/jupyterlab-jupytext-extension/ui-tests/README.md Command to start the JupyterLab server, which is required before using the Playwright code generator. ```sh cd ./ui-tests jlpm start ``` -------------------------------- ### Install Jupytext Extension for JupyterLab 1.x Source: https://github.com/mwouts/jupytext/blob/main/docs/install.md Install a specific version of the jupyterlab-jupytext extension compatible with JupyterLab 1.x. ```bash jupyter labextension install jupyterlab-jupytext@1.1.1 ``` -------------------------------- ### Light Format Example with Markdown and Code Cells Source: https://github.com/mwouts/jupytext/blob/main/docs/formats-scripts.md Demonstrates the light format, where comments adjacent to code are Markdown cells and blank lines separate cells. ```python # This is a multiline # Markdown cell # Another Markdown cell # This is a code cell class A(): def one(): return 1 def two(): return 2 ``` -------------------------------- ### Install Jupytext Extension for JupyterLab 2.x Source: https://github.com/mwouts/jupytext/blob/main/docs/install.md Install a specific version of the jupyterlab-jupytext extension compatible with JupyterLab 2.x. ```bash jupyter labextension install jupyterlab-jupytext@1.2.2 ``` -------------------------------- ### Install Development Branch from GitHub Source: https://github.com/mwouts/jupytext/blob/main/docs/developing.md Installs a specific development branch from Jupytext's GitHub repository. Replace 'branch' with the desired branch name. Requires Node.js. ```bash HATCH_BUILD_HOOKS_ENABLE=true pip install git+https://github.com/mwouts/jupytext.git@branch ``` -------------------------------- ### Percent Format Example with Markdown and Code Cells Source: https://github.com/mwouts/jupytext/blob/main/docs/formats-scripts.md Illustrates the percent format with explicit markdown and code cells. ```python # %% [markdown] # This is a multiline # Markdown cell # %% [markdown] # Another Markdown cell # %% # This is a code cell class A(): def one(): return 1 def two(): return 2 ``` -------------------------------- ### Install Jupytext Extension for JupyterLab 3.x Source: https://github.com/mwouts/jupytext/blob/main/docs/install.md Install a specific version of the jupyterlab-jupytext extension compatible with JupyterLab 3.x. ```bash jupyter labextension install jupyterlab-jupytext@1.3.11 ``` -------------------------------- ### Install SOS-notebook and related packages Source: https://github.com/mwouts/jupytext/blob/main/tests/data/notebooks/inputs/ipynb_sos/jupytext_replication.ipynb Installs a specific version of R and the necessary SOS-notebook, jupyterlab-sos, and sos-papermill packages. Use this command when encountering compatibility issues with the latest R version. ```bash conda install -c r r=3.5.1 conda install sos-notebook jupyterlab-sos sos-papermill -c conda-forge ``` -------------------------------- ### Import Libraries and Configure Pandas Source: https://github.com/mwouts/jupytext/blob/main/demo/World population.myst.md Imports necessary libraries (pandas, wbdata) and sets display options for pandas DataFrames. Ensure these libraries are installed. ```python import pandas as pd import wbdata as wb pd.options.display.max_rows = 6 pd.options.display.max_columns = 20 ``` -------------------------------- ### Install Jupytext in Development Mode Source: https://github.com/mwouts/jupytext/blob/main/docs/developing.md Installs the Jupytext package in editable mode, allowing for immediate use of local changes. Includes development dependencies. ```bash HATCH_BUILD_HOOKS_ENABLE=true pip install -e '.[dev]' ``` -------------------------------- ### Multiple Format Specifications (jupytext.toml - Mixed Formats) Source: https://github.com/mwouts/jupytext/blob/main/docs/config.md Configure Jupytext with multiple, distinct format specifications. This example pairs tutorial notebooks to markdown, example notebooks to MyST format, and all others to Python scripts. ```toml # jupytext.toml # Tutorial notebooks [[formats]] "notebooks/tutorials/" = "ipynb" "docs/tutorials/" = "md" # Example notebooks with MyST format [[formats]] "notebooks/examples/" = "ipynb" "docs/examples/" = "md:myst" # Default for all other notebooks [[formats]] "notebooks/" = "ipynb" "scripts/" = "py:percent" ``` -------------------------------- ### Define Macro Syntax Source: https://github.com/mwouts/jupytext/blob/main/tests/data/notebooks/inputs/ipynb_scheme/Reference Guide for Calysto Scheme.ipynb Use define-syntax to create custom macros. This example defines a 'time' macro to measure execution time. ```scheme (define-syntax time [(time ?exp) (let ((start (current-time))) ?exp (- (current-time) start))]) ``` ```scheme (time (car '(1 2 3 4))) ``` -------------------------------- ### Define Audio Rich Display Source: https://github.com/mwouts/jupytext/blob/main/tests/data/notebooks/inputs/ipynb_cpp/xcpp_by_quantstack.ipynb Implement mime_bundle_repr for a custom audio type to enable rich rendering. This example sets the 'text/html' MIME type for audio playback. ```cpp #include #include #include "xtl/xbase64.hpp" #include "xeus/xjson.hpp" namespace au { struct audio { inline audio(const std::string& filename) { std::ifstream fin(filename, std::ios::binary); m_buffer << fin.rdbuf(); } std::stringstream m_buffer; }; xeus::xjson mime_bundle_repr(const audio& a) { auto bundle = xeus::xjson::object(); bundle["text/html"] = std::string("