Neither jupyterlab-stata-highlight nor jupyterlab_stata_highlight2 works on Jupyter Lab 4. This is a workaround that needs to be applied everytime Jupyter Lab is updated.
- Create and activate conda environment.
conda create -n jupyterlab4 pip nodejs -c conda-forge conda activate jupyterlab4
- Install Jupyter Lab 4.
or
conda install jupyterlab -c conda-forge
pip install jupyterlab
- Set up the staging files. Make sure you are the owner of the environment, otherwise this will fail.
jupyter lab build --dev-build
- Download Stata syntax highlighting Javascript file.
wget https://raw.githubusercontent.com/ticoneva/codemirror-legacy-stata/main/stata.js -P $CONDA_PREFIX/share/jupyter/lab/staging/node_modules/@codemirror/legacy-modes/mode/
- Modify
$CONDA_PREFIX/share/jupyter/lab/staging/node_modules/@jupyterlab/codemirror/lib/language.js
. Search forSquirrel
and add the following entry after that one:
{
name: 'stata',
displayName: trans.__('Stata'),
mime: 'text/x-stata',
extensions: ['do','ado'],
async load() {
const m = await import('@codemirror/legacy-modes/mode/stata');
return legacy(m.stata);
}
},
- Run
jupyter lab build
again.