mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-13 13:17:50 +08:00
Merge pull request #5479 from jdfreder/i5135
Mixed gfm/latex parsing in codemirror
This commit is contained in:
commit
648bb51758
45
IPython/html/static/notebook/js/codemirror-ipythongfm.js
Normal file
45
IPython/html/static/notebook/js/codemirror-ipythongfm.js
Normal file
@ -0,0 +1,45 @@
|
||||
// IPython GFM (GitHub Flavored Markdown) mode is just a slightly altered GFM
|
||||
// Mode with support for latex.
|
||||
//
|
||||
// Latex support was supported by Codemirror GFM as of
|
||||
// https://github.com/marijnh/CodeMirror/pull/567
|
||||
// But was later removed in
|
||||
// https://github.com/marijnh/CodeMirror/commit/d9c9f1b1ffe984aee41307f3e927f80d1f23590c
|
||||
|
||||
CodeMirror.requireMode('gfm', function(){
|
||||
CodeMirror.requireMode('stex', function(){
|
||||
console.log('defining custom mode...');
|
||||
CodeMirror.defineMode("ipythongfm", function(config, parserConfig) {
|
||||
|
||||
var gfm_mode = CodeMirror.getMode(config, "gfm");
|
||||
var tex_mode = CodeMirror.getMode(config, "stex");
|
||||
|
||||
return CodeMirror.multiplexingMode(
|
||||
gfm_mode,
|
||||
{
|
||||
open: "$", close: "$",
|
||||
mode: tex_mode,
|
||||
delimStyle: "delimit"
|
||||
},
|
||||
{
|
||||
open: "$$", close: "$$",
|
||||
mode: tex_mode,
|
||||
delimStyle: "delimit"
|
||||
},
|
||||
{
|
||||
open: "\\(", close: "\\)",
|
||||
mode: tex_mode,
|
||||
delimStyle: "delimit"
|
||||
},
|
||||
{
|
||||
open: "\\[", close: "\\]",
|
||||
mode: tex_mode,
|
||||
delimStyle: "delimit"
|
||||
}
|
||||
// .. more multiplexed styles can follow here
|
||||
);
|
||||
}, 'gfm');
|
||||
|
||||
CodeMirror.defineMIME("text/x-ipythongfm", "ipythongfm");
|
||||
});
|
||||
});
|
@ -234,7 +234,7 @@ var IPython = (function (IPython) {
|
||||
|
||||
MarkdownCell.options_default = {
|
||||
cm_config: {
|
||||
mode: 'gfm'
|
||||
mode: 'ipythongfm'
|
||||
},
|
||||
placeholder: "Type *Markdown* and LaTeX: $\\alpha^2$"
|
||||
};
|
||||
|
@ -313,9 +313,9 @@ class="notebook_app"
|
||||
<script src="{{ static_url("components/codemirror/mode/css/css.js") }}" charset="utf-8"></script>
|
||||
<script src="{{ static_url("components/codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
|
||||
<script src="{{ static_url("components/codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
|
||||
<script src="{{ static_url("components/codemirror/mode/gfm/gfm.js") }}" charset="utf-8"></script>
|
||||
<script src="{{ static_url("components/codemirror/mode/python/python.js") }}" charset="utf-8"></script>
|
||||
<script src="{{ static_url("notebook/js/codemirror-ipython.js") }}" charset="utf-8"></script>
|
||||
<script src="{{ static_url("notebook/js/codemirror-ipythongfm.js") }}" charset="utf-8"></script>
|
||||
|
||||
<script src="{{ static_url("components/highlight.js/build/highlight.pack.js") }}" charset="utf-8"></script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user