stata_kernel
                                
                                 stata_kernel copied to clipboard
                                
                                    stata_kernel copied to clipboard
                            
                            
                            
                        Highlighting in jupyterlab not working anymore
The kernel used to have syntax highlighting, which was installed with
conda install -c conda-forge nodejs -y
jupyter labextension install jupyterlab-stata-highlight
which is not supported anymore by jupyter. Will this be updated? Actually, is this project still being maintained? I see there have been no updates in 2 years.
@ozak That's my bad; I haven't given it any attention in some time. What's your Stata versoin?
I am using Stata 18. But I think the issue is the change of "architecture" in jupyter-lab>=4.0 and notebook>=7.0.
The extension keeps asking to be built,
But when I try to build it, I get the following error message:
Build failed with 500.
        If you are experiencing the build failure after installing an extension (or trying to include previously installed extension after updating JupyterLab) please check the extension repository for new installation instructions as many extensions migrated to the prebuilt extensions system which no longer requires rebuilding JupyterLab (but uses a different installation procedure, typically involving a package manager such as 'pip' or 'conda').
        If you specifically intended to install a source extension, please run 'jupyter lab build' on the server for full output.
@ozak Is the issue specifically that this works with jupyter-lab<4.0 but not jupyter-lab>=4.0?
I think so. I am unsure which version broke it exactly.
@ozak Ok. I'm trying to test it out but I'm having problems with all the dependencies, given the bulk of the codebase hasn't been updated in a bit. I'll try and get this working with newer versions of all the dependencies soonish.
Great Thanks!
Related: https://github.com/kylebarron/jupyterlab-stata-highlight/issues/15
Instructions for a workaround meanwhile: https://github.com/hugetim/jupyterlab_stata_highlight2/issues/4#issuecomment-1895226860
Tried it and didn't work in my install.
I have verified that the following steps should work:
- Create and activate conda environment.
conda create -n jupyterlab4 pip nodejs -c conda-forge conda activate jupyterlab4
- Install Jupyter Lab 4.
 orconda install jupyterlab -c conda-forgepip 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 forSquirreland 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 buildagain.