Getting syntax highlighting to work for custom cell magic

Any news about an easy way to do it? I want support for the iTikZ magic extension: iTikZ GitHub Repository. TikZ is essentially LaTeX images (text/x-stex acorrding to CodeMirror: sTeX mode).

EDITED:

I found an easier solution to add support to highlight a custom magic cell that uses an existing language server in jupyterlab-lsp. The example below extending latex syntax.

  1. Go to extractors.ts and find these lines:

Now add support to itikz and tikz magic cells:

    new RegExpForeignCodeExtractor({
      language: 'latex',
      pattern: '^%%(latex|itikz|tikz)( .*?)?\n([^]*)', 
      foreignCaptureGroups: [3],
      isStandalone: false,
      fileExtension: 'tex'
    }),

Please comment if you know how to improve my solution.

1 Like