Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50654 views
1
// IPython GFM (GitHub Flavored Markdown) mode is just a slightly altered GFM
2
// Mode with support for latex.
3
//
4
// Latex support was supported by Codemirror GFM as of
5
// https://github.com/codemirror/CodeMirror/pull/567
6
// But was later removed in
7
// https://github.com/codemirror/CodeMirror/commit/d9c9f1b1ffe984aee41307f3e927f80d1f23590c
8
9
10
(function(mod) {
11
if (typeof exports == "object" && typeof module == "object"){ // CommonJS
12
mod(require("codemirror/lib/codemirror")
13
,require("codemirror/addon/mode/multiplex")
14
,require("codemirror/mode/gfm/gfm")
15
,require("codemirror/mode/stex/stex")
16
);
17
} else if (typeof define == "function" && define.amd){ // AMD
18
define(["codemirror/lib/codemirror"
19
,"codemirror/addon/mode/multiplex"
20
,"codemirror/mode/python/python"
21
,"codemirror/mode/stex/stex"
22
], mod);
23
} else {// Plain browser env
24
mod(CodeMirror);
25
}
26
})( function(CodeMirror){
27
"use strict";
28
29
CodeMirror.defineMode("ipythongfm", function(config, parserConfig) {
30
31
var gfm_mode = CodeMirror.getMode(config, "gfm");
32
var tex_mode = CodeMirror.getMode(config, "stex");
33
34
return CodeMirror.multiplexingMode(
35
gfm_mode,
36
{
37
open: "$", close: "$",
38
mode: tex_mode,
39
delimStyle: "delimit"
40
},
41
{
42
// not sure this works as $$ is interpreted at (opening $, closing $, as defined just above)
43
open: "$$", close: "$$",
44
mode: tex_mode,
45
delimStyle: "delimit"
46
},
47
{
48
open: "\\(", close: "\\)",
49
mode: tex_mode,
50
delimStyle: "delimit"
51
},
52
{
53
open: "\\[", close: "\\]",
54
mode: tex_mode,
55
delimStyle: "delimit"
56
}
57
// .. more multiplexed styles can follow here
58
);
59
}, 'gfm');
60
61
CodeMirror.defineMIME("text/x-ipythongfm", "ipythongfm");
62
})
63
64