mirror of
https://github.com/IHaskell/IHaskell.git
synced 2025-04-15 19:06:06 +00:00
Fixing pager Javascript
This commit is contained in:
parent
f0ab46685a
commit
b2dfd0e48f
@ -10,55 +10,53 @@ define(['require',
|
||||
var onload = function(){
|
||||
console.log('Kernel haskell kernel.js is loading.');
|
||||
|
||||
events.on('app_initialized.NotebookApp', function(){
|
||||
// add here logic that shoudl be run once per **page load**
|
||||
// like adding specific UI, or changing the default value
|
||||
// of codecell highlight.
|
||||
// add here logic that shoudl be run once per **page load**
|
||||
// like adding specific UI, or changing the default value
|
||||
// of codecell highlight.
|
||||
|
||||
// Set tooltips to be triggered after 800ms
|
||||
IPython.tooltip.time_before_tooltip = 800;
|
||||
// Set tooltips to be triggered after 800ms
|
||||
IPython.tooltip.time_before_tooltip = 800;
|
||||
|
||||
// IPython keycodes.
|
||||
var space = 32;
|
||||
var downArrow = 40;
|
||||
IPython.keyboard.keycodes.down = downArrow; // space
|
||||
// IPython keycodes.
|
||||
var space = 32;
|
||||
var downArrow = 40;
|
||||
IPython.keyboard.keycodes.down = downArrow; // space
|
||||
|
||||
IPython.CodeCell.options_default['cm_config']['mode'] = 'haskell';
|
||||
IPython.CodeCell.options_default['cm_config']['mode'] = 'haskell';
|
||||
|
||||
utils.requireCodeMirrorMode('haskell', function(){
|
||||
// Create a multiplexing mode that uses Haskell highlighting by default but
|
||||
// doesn't highlight command-line directives.
|
||||
CodeMirror.defineMode("ihaskell", function(config) {
|
||||
return CodeMirror.multiplexingMode(
|
||||
CodeMirror.getMode(config, "haskell"),
|
||||
{
|
||||
open: /:(?=!)/, // Matches : followed by !, but doesn't consume !
|
||||
close: /^(?!!)/, // Matches start of line not followed by !, doesn't consume character
|
||||
mode: CodeMirror.getMode(config, "text/plain"),
|
||||
delimStyle: "delimit"
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
cells = IPython.notebook.get_cells();
|
||||
for(var i in cells){
|
||||
c = cells[i];
|
||||
if (c.cell_type === 'code') {
|
||||
// Force the mode to be Haskell
|
||||
// This is necessary, otherwise sometimes highlighting just doesn't happen.
|
||||
// This may be an IPython bug.
|
||||
c.code_mirror.setOption('mode', 'ihaskell');
|
||||
c.auto_highlight();
|
||||
utils.requireCodeMirrorMode('haskell', function(){
|
||||
// Create a multiplexing mode that uses Haskell highlighting by default but
|
||||
// doesn't highlight command-line directives.
|
||||
CodeMirror.defineMode("ihaskell", function(config) {
|
||||
return CodeMirror.multiplexingMode(
|
||||
CodeMirror.getMode(config, "haskell"),
|
||||
{
|
||||
open: /:(?=!)/, // Matches : followed by !, but doesn't consume !
|
||||
close: /^(?!!)/, // Matches start of line not followed by !, doesn't consume character
|
||||
mode: CodeMirror.getMode(config, "text/plain"),
|
||||
delimStyle: "delimit"
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Prevent the pager from surrounding everything with a <pre>
|
||||
IPython.Pager.prototype.append_text = function (text) {
|
||||
this.pager_element.find(".container").append($('<div/>').html(IPython.utils.autoLinkUrls(text)));
|
||||
};
|
||||
cells = IPython.notebook.get_cells();
|
||||
for(var i in cells){
|
||||
c = cells[i];
|
||||
if (c.cell_type === 'code') {
|
||||
// Force the mode to be Haskell
|
||||
// This is necessary, otherwise sometimes highlighting just doesn't happen.
|
||||
// This may be an IPython bug.
|
||||
c.code_mirror.setOption('mode', 'ihaskell');
|
||||
c.auto_highlight();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Prevent the pager from surrounding everything with a <pre>
|
||||
IPython.Pager.prototype.append_text = function (text) {
|
||||
this.pager_element.find(".container").append($('<div/>').html(IPython.utils.autoLinkUrls(text)));
|
||||
};
|
||||
|
||||
events.on('shell_reply.Kernel', function() {
|
||||
// Add logic here that should be run once per reply.
|
||||
|
||||
@ -69,17 +67,17 @@ define(['require',
|
||||
$code = $this.html(),
|
||||
$unescaped = $('<div/>').html($code).text();
|
||||
|
||||
$this.empty();
|
||||
$this.empty();
|
||||
|
||||
// Never highlight this block again.
|
||||
this.className = "";
|
||||
// Never highlight this block again.
|
||||
this.className = "";
|
||||
|
||||
CodeMirror(this, {
|
||||
value: $unescaped,
|
||||
mode: this.id,
|
||||
lineNumbers: false,
|
||||
readOnly: true
|
||||
});
|
||||
CodeMirror(this, {
|
||||
value: $unescaped,
|
||||
mode: this.id,
|
||||
lineNumbers: false,
|
||||
readOnly: true
|
||||
});
|
||||
});
|
||||
});
|
||||
console.log('IHaskell kernel.js should have been loaded.')
|
||||
|
Loading…
x
Reference in New Issue
Block a user