Jupyterlab extension to highlight Stan syntax
Project description
jupyterlab-stan-highlight
JupyterLab extension to highlight Stan syntax in notebooks and standalone Stan files.
This extension has been updated to work with JupyterLab 4.0+ and uses CodeMirror 6 for syntax highlighting.
Modeled on the VSCode grammar and uses stan-language-definitions
Use it with CmdStanJupyter to receive
highlighting for your %%stan blocks in python notebooks!
Features
- Syntax highlighting for
.stanfiles - Automatic highlighting for
%%stanmagic cells in Jupyter notebooks - Support for Stan language constructs including:
- Data types (int, real, vector, matrix, etc.)
- Control flow (for, while, if, else)
- Distributions and functions
- Comments and preprocessor directives
Prerequisites
- JupyterLab 4.0 or later
Installation
From PyPI (Recommended)
pip install jupyterlab-stan-highlight
Development Installation
For a development install, clone this repository and run:
pip install -e .
# Or if you prefer to use conda/mamba
# conda install -c conda-forge jupyterlab nodejs
# mamba install -c conda-forge jupyterlab nodejs
# Install dependencies
jlpm install
# Build the extension
jlpm run build
# Install the extension for development
jupyter labextension develop . --overwrite
Usage
-
Stan Files: Open any
.stanfile in JupyterLab and syntax highlighting will be applied automatically. -
Notebook Magic Cells: In a Jupyter notebook, create a code cell that starts with
%%stanand the rest of the cell content will be highlighted as Stan code:
%%stan
data {
int<lower=0> N;
vector[N] y;
}
parameters {
real mu;
real<lower=0> sigma;
}
model {
y ~ normal(mu, sigma);
}
Building
To build the extension:
jlpm run build
To build for production:
jlpm run build:prod
Changes from Previous Version
This version (0.4.0+) includes major updates for JupyterLab 4 compatibility:
- Migrated from CodeMirror 5 to CodeMirror 6
- Updated to use JupyterLab 4 APIs
- Modernized build system using
@jupyterlab/builder - Added TypeScript support
- Improved magic cell detection
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jupyterlab4_stan_highlight-0.4.0.tar.gz.
File metadata
- Download URL: jupyterlab4_stan_highlight-0.4.0.tar.gz
- Upload date:
- Size: 137.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82b8d0d3246062d512d4f9d48c7a459a12806cbd56f51a831edcb33b3b18dc91
|
|
| MD5 |
a5cd2661d2b912cd6d185c0ccf56b016
|
|
| BLAKE2b-256 |
cf9bbf9d2071897da0af58bc914b55a66cbca73cf8c0e5c00a50ce3792527482
|
File details
Details for the file jupyterlab4_stan_highlight-0.4.0-py3-none-any.whl.
File metadata
- Download URL: jupyterlab4_stan_highlight-0.4.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b6dbad154df9c2028e4e0246a7f14311e9f35fe9fe205e4245fd0d556bfa467
|
|
| MD5 |
d87133d804c17a9517b9ac3b42fa86cd
|
|
| BLAKE2b-256 |
889fc38be77a64a373e032aff8944fdefa78a1126ff576a1f262043f0d7c0d90
|