Unverified Commit 7a4c4869 authored by Vaibhav Sagar's avatar Vaibhav Sagar Committed by GitHub

jupyterlab-ihaskell: make compatible with JupyterLab 3 (#1267)

parent 0ff0e319
......@@ -809,6 +809,15 @@
"defer-to-connect": "^1.0.1"
}
},
"@types/codemirror": {
"version": "5.60.2",
"resolved": "https://registry.npmjs.org/@types/codemirror/-/codemirror-5.60.2.tgz",
"integrity": "sha512-tk8YxckrdU49GaJYRKxdzzzXrTlyT2nQGnobb8rAk34jt+kYXOxPKGqNgr7SJpl5r6YGaRD4CDfqiL+6A+/z7w==",
"dev": true,
"requires": {
"@types/tern": "*"
}
},
"@types/dom4": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@types/dom4/-/dom4-2.0.2.tgz",
......@@ -901,6 +910,15 @@
"integrity": "sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==",
"dev": true
},
"@types/tern": {
"version": "0.23.4",
"resolved": "https://registry.npmjs.org/@types/tern/-/tern-0.23.4.tgz",
"integrity": "sha512-JAUw1iXGO1qaWwEOzxTKJZ/5JxVeON9kvGZ/osgZaJImBnyjyn0cjovPsf6FNLmyGY8Vw9DoXZCMlfMkMwHRWg==",
"dev": true,
"requires": {
"@types/estree": "*"
}
},
"@types/webpack-sources": {
"version": "0.1.9",
"resolved": "https://registry.npmjs.org/@types/webpack-sources/-/webpack-sources-0.1.9.tgz",
......
{
"name": "jupyterlab-ihaskell",
"version": "0.0.13",
"version": "0.0.14",
"description": "adds ihaskell syntax highlighting to jupyterlab",
"keywords": [
"jupyter",
......@@ -15,8 +15,7 @@
"license": "BSD-3-Clause",
"author": "MMesch",
"files": [
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}"
"lib/**/*.{d.ts,js,js.map,json}"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
......@@ -31,6 +30,7 @@
},
"dependencies": {
"@jupyterlab/application": ">=3.0.0",
"@jupyterlab/codemirror": ">=3.0.0",
"@jupyterlab/apputils": ">=3.0.0",
"@jupyterlab/docregistry": ">=3.0.0",
"@jupyterlab/notebook": ">=3.0.0",
......@@ -40,7 +40,8 @@
"devDependencies": {
"rimraf": "^3.0.0",
"typescript": "~3.7.3",
"@jupyterlab/builder": "^3.0.8"
"@types/codemirror": ">=0.0.0",
"@jupyterlab/builder": ">=3.0.0"
},
"jupyterlab": {
"extension": true,
......
import * as CodeMirror from 'codemirror';
// @ts-nocheck
// The types for CodeMirror don't accept a RegExp for 'open' and 'close'
import 'codemirror/lib/codemirror';
import 'codemirror/mode/haskell/haskell';
import { ICodeMirror, Mode } from '@jupyterlab/codemirror';
CodeMirror.defineMode("ihaskell", (config) => {
let hmode = CodeMirror.getMode(config, "haskell");
return CodeMirror.multiplexingMode(
hmode,
{
open: /:(?=!)/, // Matches : followed by !, but doesn't consume !
close: /^(?!!)/, // Matches start of line not followed by !, doesn't consume character
mode: CodeMirror.getMode(config, "text/plain"),
delimStyle: "delimit"
},
{
open: /\[r\||\[rprint\||\[rgraph\|/,
close: /\|\]/ ,
mode: CodeMirror.getMode(config, "text/x-rsrc"),
delimStyle: "delimit"}
);
});
export function defineIHaskellMode({ CodeMirror }: ICodeMirror) {
Mode.ensure("haskell");
Mode.ensure("r");
CodeMirror.defineMode("ihaskell", (config) => {
let hmode = CodeMirror.getMode(config, "haskell");
return CodeMirror.multiplexingMode(
hmode,
{
open: /:(?=!)/, // Matches : followed by !, but doesn't consume !
close: /^(?!!)/, // Matches start of line not followed by !, doesn't consume character
mode: CodeMirror.getMode(config, "text/plain"),
delimStyle: "delimit"
},
{
open: /\[r\||\[rprint\||\[rgraph\|/,
close: /\|\]/,
mode: CodeMirror.getMode(config, "text/x-rsrc"),
delimStyle: "delimit"
}
);
});
CodeMirror.defineMIME("text/x-ihaskell", "ihaskell");
CodeMirror.defineMIME("text/x-ihaskell", "ihaskell");
CodeMirror.modeInfo.push({
ext: ['hs'],
mime: "text/x-ihaskell",
mode: 'ihaskell',
name: 'ihaskell'
});
CodeMirror.modeInfo.push({
ext: ['hs'],
mime: "text/x-ihaskell",
mode: 'ihaskell',
name: 'ihaskell'
});
}
......@@ -2,9 +2,9 @@ import {
JupyterFrontEnd, JupyterFrontEndPlugin
} from '@jupyterlab/application';
import './codemirror-ihaskell';
import { ICodeMirror } from '@jupyterlab/codemirror';
import '../style/index.css';
import { defineIHaskellMode } from './codemirror-ihaskell';
/**
* Initialization data for the extension1 extension.
......@@ -12,17 +12,12 @@ import '../style/index.css';
const extension: JupyterFrontEndPlugin<void> = {
id: 'ihaskell',
autoStart: true,
requires: [],
activate: (app: JupyterFrontEnd) =>
requires: [ICodeMirror],
activate: (app: JupyterFrontEnd, codeMirror: ICodeMirror) =>
{
app.serviceManager.ready
.then(() => {defineIHaskell()});
defineIHaskellMode(codeMirror);
console.log('ihaskell codemirror activated');
}
};
function defineIHaskell() {
console.log('ihaskell codemirror activated');
}
export default extension;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment