// https://github.com/nteract/nteract/issues/389
import CodeMirror from "codemirror";

import "codemirror/mode/meta";
import "codemirror/mode/python/python";

CodeMirror.defineMode(
  "ipython",
  (
    conf: CodeMirror.EditorConfiguration,
    parserConf: any
  ): CodeMirror.Mode<any> => {
    const ipythonConf = Object.assign({}, parserConf, {
      name: "python",
      singleOperators: new RegExp("^[\\+\\-\\*/%&|@\\^~<>!\\?]"),
      identifiers: new RegExp(
        "^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*"
      ) // Technically Python3
    });
    return CodeMirror.getMode(conf, ipythonConf);
  },
  "python"
);

CodeMirror.defineMIME("text/x-ipython", "ipython");

// https://github.com/nteract/nteract/issues/389
import CodeMirror from "codemirror";

import "codemirror/mode/meta";
import "codemirror/mode/python/python";

CodeMirror.defineMode(
  "text/x-ipython",
  (
    conf: CodeMirror.EditorConfiguration,
    parserConf: any
  ): CodeMirror.Mode<any> => {
    const ipythonConf = Object.assign({}, parserConf, {
      name: "python",
      singleOperators: new RegExp("^[\\+\\-\\*/%&|@\\^~<>!\\?]"),
      identifiers: new RegExp(
        "^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*"
      ) // Technically Python3
    });
    return CodeMirror.getMode(conf, ipythonConf);
  },
  "python"
);

CodeMirror.defineMIME("text/x-ipython", "ipython");

--- 
+++ 
@@ -5,7 +5,7 @@
 import "codemirror/mode/python/python";
 
 CodeMirror.defineMode(
-  "text/x-ipython",
+  "ipython",
   (
     conf: CodeMirror.EditorConfiguration,
     parserConf: any
Fix syntax highlighting for Python
