Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {
- JupyterFrontEnd,
- JupyterFrontEndPlugin
- } from '@jupyterlab/application';
- import {
- IEditorLanguageRegistry
- } from '@jupyterlab/codemirror'
- import { LanguageSupport, LRLanguage } from '@codemirror/language';
- import { buildParser } from '@lezer/generator';
- /**
- * Initialization data for the unicodelab-ts extension.
- */
- export const algorithm_plugin: JupyterFrontEndPlugin<void> = {
- id: 'unicodelab-ts:algorithm',
- autoStart: true,
- // provides: snippetToken, // For providing services
- requires: [IEditorLanguageRegistry],
- optional: [],
- activate: (
- app: JupyterFrontEnd,
- lang_registry: IEditorLanguageRegistry
- ) => {
- lang_registry.addLanguage({
- name: 'algorithm',
- mime: 'text/algorithm',
- support: new LanguageSupport(
- // dummy parser that accepts nothing
- LRLanguage.define({
- parser: buildParser(`
- @top Program { word word* ";" }
- @tokens {
- spaces[@export] { $[\u0009 \u000b\u00a0\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]+ }
- newline[@export] { $[\r\n\u2028\u2029] }
- wordLetter { @asciiLetter }
- word { wordLetter+ }
- @precedence { spaces, newline, word }
- ";"
- }
- @external propSource algorithmHighlight from "./highlight.ts"
- `)
- })
- )
- });
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement