##// END OF EJS Templates
Fix issue #5877 with tests...
Fix issue #5877 with tests This pull request prevent to have lists environments inside the headings cells which break latex code. - First, the function `markdown2latex` has been changed in order to accept a markup keyword for pandoc reader, default to `markdown` as before(`test_markdown.py` updated too). - Headings cells are treated with markup `markdown_strict+tex_math_dollars` to remove enhancements of pandoc for lists and add math support. - Secondly, `prevent_list_blocks` filter escape characters `. - * +` in headings cells to prevent `enumerate` or `itemize` environments in latex sections(test added in `test_strings.py` Test files accessible at: <https://gist.github.com/benjaminabel/4a40d1300dcf087c8695&gt;

File last commit:

r18032:bed6b8ed
r18427:7b2e741d
Show More
kernelselector.js
91 lines | 3.4 KiB | application/javascript | JavascriptLexer
Thomas Kluyver
Allow switching kernel from the notebook UI
r17370 // Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'base/js/namespace',
'jquery',
'base/js/utils',
], function(IPython, $, utils) {
"use strict";
var KernelSelector = function(selector, notebook) {
this.selector = selector;
this.notebook = notebook;
Thomas Kluyver
Use JS events for switching kernelspecs
r17380 this.events = notebook.events;
MinRK
allow kernel_name to be undefined in js...
r18032 this.current_selection = null;
Thomas Kluyver
Allow switching kernel from the notebook UI
r17370 this.kernelspecs = {};
if (this.selector !== undefined) {
this.element = $(selector);
this.request_kernelspecs();
}
Thomas Kluyver
Use JS events for switching kernelspecs
r17380 this.bind_events();
Thomas Kluyver
Address review comments
r17392 // Make the object globally available for user convenience & inspection
IPython.kernelselector = this;
Thomas Kluyver
Allow switching kernel from the notebook UI
r17370 };
KernelSelector.prototype.request_kernelspecs = function() {
var url = utils.url_join_encode(this.notebook.base_url, 'api/kernelspecs');
Thomas Kluyver
Address review comments
r17392 $.ajax(url, {success: $.proxy(this._got_kernelspecs, this)});
Thomas Kluyver
Allow switching kernel from the notebook UI
r17370 };
Thomas Kluyver
Address review comments
r17392 KernelSelector.prototype._got_kernelspecs = function(data, status, xhr) {
Thomas Kluyver
Allow switching kernel from the notebook UI
r17370 this.kernelspecs = {};
var menu = this.element.find("#kernel_selector");
Thomas Kluyver
Add submenu under kernel for changing kernel
r17387 var change_kernel_submenu = $("#menu-change-kernel-submenu");
Thomas Kluyver
Allow switching kernel from the notebook UI
r17370 for (var i = 0; i < data.length; i++) {
var ks = data[i];
this.kernelspecs[ks.name] = ks;
var ksentry = $("<li>").attr("id", "kernel-" +ks.name).append($('<a>')
.attr('href', '#')
.click($.proxy(this.change_kernel, this, ks.name))
.text(ks.display_name));
menu.append(ksentry);
Thomas Kluyver
Add submenu under kernel for changing kernel
r17387
var ks_submenu_entry = $("<li>").attr("id", "kernel-submenu-"+ks.name).append($('<a>')
.attr('href', '#')
.click($.proxy(this.change_kernel, this, ks.name))
.text(ks.display_name));
change_kernel_submenu.append(ks_submenu_entry);
Thomas Kluyver
Allow switching kernel from the notebook UI
r17370 }
};
KernelSelector.prototype.change_kernel = function(kernel_name) {
Thomas Kluyver
Don't refer to global kernelselector object in Session
r17384 if (kernel_name === this.current_selection) {
Thomas Kluyver
Allow switching kernel from the notebook UI
r17370 return;
}
Thomas Kluyver
Use JS events for switching kernelspecs
r17380 var ks = this.kernelspecs[kernel_name];
MinRK
avoid race condition when deleting/starting sessions...
r17649 try {
this.notebook.start_session(kernel_name);
} catch (e) {
if (e.name === 'SessionAlreadyStarting') {
console.log("Cannot change kernel while waiting for pending session start.");
} else {
// unhandled error
throw e;
}
// only trigger spec_changed if change was successful
return;
}
Thomas Kluyver
Use JS events for switching kernelspecs
r17380 this.events.trigger('spec_changed.Kernel', ks);
Thomas Kluyver
Allow switching kernel from the notebook UI
r17370 };
Thomas Kluyver
Use JS events for switching kernelspecs
r17380 KernelSelector.prototype.bind_events = function() {
var that = this;
this.events.on('spec_changed.Kernel', function(event, data) {
Thomas Kluyver
Don't refer to global kernelselector object in Session
r17384 that.current_selection = data.name;
Matthias BUSSONNIER
Simplify and uniformise styling of kernel selector...
r17382 that.element.find("#current_kernel_spec").find('.kernel_name').text(data.display_name);
Thomas Kluyver
Use JS events for switching kernelspecs
r17380 });
Thomas Kluyver
Don't refer to global kernelselector object in Session
r17384
this.events.on('started.Session', function(events, session) {
if (session.kernel_name !== that.current_selection) {
// If we created a 'python' session, we only know if it's Python
// 3 or 2 on the server's reply, so we fire the event again to
// set things up.
var ks = that.kernelspecs[session.kernel_name];
that.events.trigger('spec_changed.Kernel', ks);
}
});
Thomas Kluyver
Change displayed kernel name when our session is started
r17371 };
Thomas Kluyver
Allow switching kernel from the notebook UI
r17370 return {'KernelSelector': KernelSelector};
});