mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-19 13:20:36 +08:00
Merge pull request #3364 from Carreau/requirejs
Inject requirejs in notebook and start using it. Mainly because the behavior of Marked change when require is injected. So only apply the modification needed for marked to behave.
This commit is contained in:
commit
6938e76ccc
@ -8,17 +8,27 @@
|
||||
//============================================================================
|
||||
// On document ready
|
||||
//============================================================================
|
||||
"use strict";
|
||||
|
||||
// for the time beeing, we have to pass marked as a parameter here,
|
||||
// as injecting require.js make marked not to put itself in the globals,
|
||||
// which make both this file fail at setting marked configuration, and textcell.js
|
||||
// which search marked into global.
|
||||
require(['components/marked/lib/marked'],
|
||||
|
||||
$(document).ready(function () {
|
||||
function (marked) {
|
||||
|
||||
window.marked = marked
|
||||
|
||||
// monkey patch CM to be able to syntax highlight cell magics
|
||||
// bug reported upstream,
|
||||
// see https://github.com/marijnh/CodeMirror2/issues/670
|
||||
if(CodeMirror.getMode(1,'text/plain').indent == undefined ){
|
||||
console.log('patching CM for undefined indent');
|
||||
CodeMirror.modes.null = function() { return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0}}}
|
||||
CodeMirror.modes.null = function() {
|
||||
return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0}}
|
||||
}
|
||||
}
|
||||
|
||||
CodeMirror.patchedGetMode = function(config, mode){
|
||||
var cmmode = CodeMirror.getMode(config, mode);
|
||||
@ -90,10 +100,10 @@ $(document).ready(function () {
|
||||
// only do this once
|
||||
$([IPython.events]).off('notebook_loaded.Notebook', first_load);
|
||||
};
|
||||
|
||||
|
||||
$([IPython.events]).on('notebook_loaded.Notebook', first_load);
|
||||
IPython.notebook.load_notebook($('body').data('notebookId'));
|
||||
|
||||
|
||||
if (marked) {
|
||||
marked.setOptions({
|
||||
gfm : true,
|
||||
@ -110,6 +120,6 @@ $(document).ready(function () {
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
);
|
||||
|
@ -206,7 +206,6 @@ class="notebook_app"
|
||||
<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/marked/lib/marked.js") }}" charset="utf-8"></script>
|
||||
<script src="{{ static_url("components/highlight.js/build/highlight.pack.js") }}" charset="utf-8"></script>
|
||||
|
||||
<script src="{{ static_url("dateformat/date.format.js") }}" charset="utf-8"></script>
|
||||
|
@ -24,7 +24,12 @@
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
<link rel="stylesheet" href="{{ static_url("custom/custom.css") }}" type="text/css" />
|
||||
|
||||
<script src="{{static_url("components/requirejs/require.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script>
|
||||
require.config({
|
||||
baseUrl: '{{static_url() }}',
|
||||
});
|
||||
</script>
|
||||
|
||||
{% block meta %}
|
||||
{% endblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user