import CodeMirror, { Doc } from 'codemirror'

export function init (rootEl) {
  return CodeMirror(rootEl)
}

export function openDoc (cm, content) {
  const newDoc = Doc(content)
  cm.swapDoc(newDoc)
  return newDoc
}

@@ -43,66 +43,318 @@
 r'%0A%0A
-export function init (rootEl) %7B%0A  return CodeMirror(rootEl
+import LatexParser from './ide/editor/codemirror/parser'%0A%0Aexport function init (rootEl) %7B%0A  CodeMirror.defineMode('latex', () =%3E new LatexParser())%0A  CodeMirror.defineMIME('application/x-tex', 'latex')%0A  CodeMirror.defineMIME('application/x-latex', 'latex')%0A%0A  return CodeMirror(rootEl, %7B%0A    mode: 'latex'%0A  %7D
 )%0A%7D%0A
@@ -422,16 +422,25 @@
 (content
+, 'latex'
 )%0A  cm.s

Configure CM with latex parser