Skip to content

Changes needed to add Stata syntax highlighting to Jupyter Lab 4

Notifications You must be signed in to change notification settings

ticoneva/codemirror-legacy-stata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Stata Syntax Highlighting for Jupyter Lab 4

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.

  1. Create and activate conda environment.
    conda create -n jupyterlab4 pip nodejs -c conda-forge
    conda activate jupyterlab4
  2. Install Jupyter Lab 4.
    conda install jupyterlab -c conda-forge
    or
    pip install jupyterlab
  3. Set up the staging files. Make sure you are the owner of the environment, otherwise this will fail.
    jupyter lab build --dev-build
  4. 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/
  5. Modify $CONDA_PREFIX/share/jupyter/lab/staging/node_modules/@jupyterlab/codemirror/lib/language.js. Search for Squirrel 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);
                }
            },
  1. Run jupyter lab build again.

About

Changes needed to add Stata syntax highlighting to Jupyter Lab 4

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published