diff --git a/.cache/pip/http-v2/0/4/1/8/c/0418c83b80f7f7bfaec2738bfbbee53d2c1562196c0781702f6eddc8 b/.cache/pip/http-v2/0/4/1/8/c/0418c83b80f7f7bfaec2738bfbbee53d2c1562196c0781702f6eddc8 new file mode 100644 index 0000000000000000000000000000000000000000..c2b242a36e05f03af4111c5e192fbdb5540f2aa6 Binary files /dev/null and b/.cache/pip/http-v2/0/4/1/8/c/0418c83b80f7f7bfaec2738bfbbee53d2c1562196c0781702f6eddc8 differ diff --git a/.cache/pip/http-v2/0/4/1/8/c/0418c83b80f7f7bfaec2738bfbbee53d2c1562196c0781702f6eddc8.body b/.cache/pip/http-v2/0/4/1/8/c/0418c83b80f7f7bfaec2738bfbbee53d2c1562196c0781702f6eddc8.body new file mode 100644 index 0000000000000000000000000000000000000000..43e66323542b3ad76a399b7d1aac5f24af459ed4 Binary files /dev/null and b/.cache/pip/http-v2/0/4/1/8/c/0418c83b80f7f7bfaec2738bfbbee53d2c1562196c0781702f6eddc8.body differ diff --git a/.cache/pip/http-v2/0/7/5/9/3/07593bb905dded4b84aacb1d96c1e64704669d6bab658dcaeab79c36 b/.cache/pip/http-v2/0/7/5/9/3/07593bb905dded4b84aacb1d96c1e64704669d6bab658dcaeab79c36 new file mode 100644 index 0000000000000000000000000000000000000000..9774b8eada013882f7fc7df91766f4e2b7da9d44 Binary files /dev/null and b/.cache/pip/http-v2/0/7/5/9/3/07593bb905dded4b84aacb1d96c1e64704669d6bab658dcaeab79c36 differ diff --git a/.cache/pip/http-v2/0/7/5/9/3/07593bb905dded4b84aacb1d96c1e64704669d6bab658dcaeab79c36.body b/.cache/pip/http-v2/0/7/5/9/3/07593bb905dded4b84aacb1d96c1e64704669d6bab658dcaeab79c36.body new file mode 100644 index 0000000000000000000000000000000000000000..9af5f813f65b21398d2b76b66ad1c3c1bb5464e4 Binary files /dev/null and b/.cache/pip/http-v2/0/7/5/9/3/07593bb905dded4b84aacb1d96c1e64704669d6bab658dcaeab79c36.body differ diff --git a/.cache/pip/http-v2/0/c/2/1/8/0c218d526767991766d9b365a4f3e4449ce3579fd8b0f96a707d5a52 b/.cache/pip/http-v2/0/c/2/1/8/0c218d526767991766d9b365a4f3e4449ce3579fd8b0f96a707d5a52 new file mode 100644 index 0000000000000000000000000000000000000000..c5c76ebe1ec5a3e8870b10369cfe93b3a18bd32e Binary files /dev/null and b/.cache/pip/http-v2/0/c/2/1/8/0c218d526767991766d9b365a4f3e4449ce3579fd8b0f96a707d5a52 differ diff --git a/.cache/pip/http-v2/0/c/f/6/e/0cf6e817e2c5554000c735ecab0f3cf492f7d33b50d5a474a801ba24.body b/.cache/pip/http-v2/0/c/f/6/e/0cf6e817e2c5554000c735ecab0f3cf492f7d33b50d5a474a801ba24.body new file mode 100644 index 0000000000000000000000000000000000000000..59b5d08064db003dbae936cfa9c00264ccafa641 Binary files /dev/null and b/.cache/pip/http-v2/0/c/f/6/e/0cf6e817e2c5554000c735ecab0f3cf492f7d33b50d5a474a801ba24.body differ diff --git a/.cache/pip/http-v2/1/2/e/6/c/12e6c0100f8dcc54f1445b9845cfdcecf519882e2fe2767cf43bd439 b/.cache/pip/http-v2/1/2/e/6/c/12e6c0100f8dcc54f1445b9845cfdcecf519882e2fe2767cf43bd439 new file mode 100644 index 0000000000000000000000000000000000000000..215b3754c7587a429e5ee53f783973b8a10dd0cf Binary files /dev/null and b/.cache/pip/http-v2/1/2/e/6/c/12e6c0100f8dcc54f1445b9845cfdcecf519882e2fe2767cf43bd439 differ diff --git a/.cache/pip/http-v2/1/6/9/3/2/1693297fb9daf7bfe370bf51d371acfeb8ff40759bf8650dfd404ba4 b/.cache/pip/http-v2/1/6/9/3/2/1693297fb9daf7bfe370bf51d371acfeb8ff40759bf8650dfd404ba4 new file mode 100644 index 0000000000000000000000000000000000000000..e1740602aa29444bad5f6c314a02fa85962879c8 Binary files /dev/null and b/.cache/pip/http-v2/1/6/9/3/2/1693297fb9daf7bfe370bf51d371acfeb8ff40759bf8650dfd404ba4 differ diff --git a/.local/share/jupyter/nbextensions/codefolding/main.js b/.local/share/jupyter/nbextensions/codefolding/main.js new file mode 100644 index 0000000000000000000000000000000000000000..6c512db130b85ca8ef4a361cb5448cf5c4f8c282 --- /dev/null +++ b/.local/share/jupyter/nbextensions/codefolding/main.js @@ -0,0 +1,282 @@ +// Allow codefolding in code cells +// +// This extension enables the CodeMirror feature +// It works by adding a gutter area to each code cell. +// Fold-able code is marked using small triangles in the gutter. +// +// The current folding state is saved in the cell metadata as an array +// of line numbers. +// Format: cell.metadata.code_folding = [ line1, line2, line3, ...] +// + +define([ + 'base/js/namespace', + 'jquery', + 'require', + 'base/js/events', + 'services/config', + 'notebook/js/codecell', + 'codemirror/lib/codemirror', + 'codemirror/addon/fold/foldcode', + 'codemirror/addon/fold/foldgutter', + 'codemirror/addon/fold/brace-fold', + 'codemirror/addon/fold/indent-fold' +], function (Jupyter, $, requirejs, events, configmod, codecell, CodeMirror) { + "use strict"; + + // define default config parameter values + var params = { + codefolding_hotkey : 'Alt-f', + init_delay : 1000 + }; + + // updates default params with any specified in the provided config data + var update_params = function (config_data) { + for (var key in params) { + if (config_data.hasOwnProperty(key)) { + params[key] = config_data[key]; + } + } + }; + + var on_config_loaded = function () { + if (Jupyter.notebook !== undefined) { + // register actions with ActionHandler instance + var prefix = 'auto'; + var name = 'toggle-codefolding'; + var action = { + icon: 'fa-comment-o', + help : 'Toggle codefolding', + help_index : 'ec', + id : 'toggle_codefolding', + handler : toggleFolding + }; + var action_full_name = Jupyter.keyboard_manager.actions.register(action, name, prefix); + + // define keyboard shortcuts + var edit_mode_shortcuts = {}; + edit_mode_shortcuts[params.codefolding_hotkey] = action_full_name; + + // register keyboard shortcuts with keyboard_manager + Jupyter.notebook.keyboard_manager.edit_shortcuts.add_shortcuts(edit_mode_shortcuts); + Jupyter.notebook.keyboard_manager.command_shortcuts.add_shortcuts(edit_mode_shortcuts); + } + else { + // we're in edit view + var extraKeys = Jupyter.editor.codemirror.getOption('extraKeys'); + extraKeys[params.codefolding_hotkey] = toggleFolding; + CodeMirror.normalizeKeyMap(extraKeys); + console.log('[codefolding] binding hotkey', params.codefolding_hotkey); + Jupyter.editor.codemirror.setOption('extraKeys', extraKeys); + } + }; + + /* + * Toggle folding on/off at current line + * + * @param cm CodeMirror instance + * + */ + function toggleFolding () { + var cm; + var pos = {line: 0, ch: 0, xRel: 0}; + if (Jupyter.notebook !== undefined) { + cm = Jupyter.notebook.get_selected_cell().code_mirror; + if (Jupyter.notebook.mode === 'edit') { + pos = cm.getCursor(); + } + } + else { + cm = Jupyter.editor.codemirror; + pos = cm.getCursor(); + } + var opts = cm.state.foldGutter.options; + cm.foldCode(pos, opts.rangeFinder); + } + + /** + * Update cell metadata with folding info, so folding state can be restored after reloading notebook + * + * @param cm CodeMirror instance + */ + function updateMetadata (cm) { + var list = cm.getAllMarks(); + var lines = []; + for (var i = 0; i < list.length; i++) { + if (list[i].__isFold) { + var range = list[i].find(); + lines.push(range.from.line); + } + } + /* User can click on gutter of unselected cells, so make sure we store metadata in the correct cell */ + var cell = Jupyter.notebook.get_selected_cell(); + if (cell.code_mirror !== cm) { + var cells = Jupyter.notebook.get_cells(); + var ncells = Jupyter.notebook.ncells(); + for (var k = 0; k < ncells; k++) { + var _cell = cells[k]; + if (_cell.code_mirror === cm ) { cell = _cell; break; } + } + } + cell.metadata.code_folding = lines; + } + + /** + * Activate codefolding in CodeMirror options, don't overwrite other settings + * + * @param cm codemirror instance + */ + function activate_cm_folding (cm) { + var gutters = cm.getOption('gutters').slice(); + if ( $.inArray("CodeMirror-foldgutter", gutters) < 0) { + gutters.push('CodeMirror-foldgutter'); + cm.setOption('gutters', gutters); + } + + /* set indent or brace folding */ + var opts = true; + if (Jupyter.notebook) { + opts = { + rangeFinder: new CodeMirror.fold.combine( + CodeMirror.fold.firstline, + CodeMirror.fold.magic, + CodeMirror.fold.blockcomment, + cm.getMode().fold === 'indent' ? CodeMirror.fold.indent : CodeMirror.fold.brace + ) + }; + } + cm.setOption('foldGutter', opts); + } + + /** + * Restore folding status from metadata + * @param cell + */ + var restoreFolding = function (cell) { + if (cell.metadata.code_folding === undefined || !(cell instanceof codecell.CodeCell)) { + return; + } + // visit in reverse order, as otherwise nested folds un-fold outer ones + var lines = cell.metadata.code_folding.slice().sort(); + for (var idx = lines.length - 1; idx >= 0; idx--) { + var line = lines[idx]; + var opts = cell.code_mirror.state.foldGutter.options; + var linetext = cell.code_mirror.getLine(line); + if (linetext !== undefined) { + cell.code_mirror.foldCode(CodeMirror.Pos(line, 0), opts.rangeFinder); + } + else { + // the line doesn't exist, so we should remove it from metadata + cell.metadata.code_folding = lines.slice(0, idx); + } + cell.code_mirror.refresh(); + } + }; + + /** + * Add codefolding gutter to a new cell + * + * @param event + * @param nbcell + * + */ + var createCell = function (event, nbcell) { + var cell = nbcell.cell; + if ((cell instanceof codecell.CodeCell)) { + activate_cm_folding(cell.code_mirror); + cell.code_mirror.on('fold', updateMetadata); + cell.code_mirror.on('unfold', updateMetadata); + // queue restoring folding, to run once metadata is set, hopefully. + // This can be useful if cells are un-deleted, for example. + setTimeout(function () { restoreFolding(cell); }, 500); + } + }; + + /* + * Initialize gutter in existing cells + * + */ + var initExistingCells = function () { + var cells = Jupyter.notebook.get_cells(); + var ncells = Jupyter.notebook.ncells(); + for (var i = 0; i < ncells; i++) { + var cell = cells[i]; + if ((cell instanceof codecell.CodeCell)) { + activate_cm_folding(cell.code_mirror); + /* restore folding state if previously saved */ + restoreFolding(cell); + cell.code_mirror.on('fold', updateMetadata); + cell.code_mirror.on('unfold', updateMetadata); + } + } + events.on('create.Cell', createCell); + }; + + /** + * Load my own CSS file + * + * @param name off CSS file + * + */ + var load_css = function (name) { + var link = document.createElement("link"); + link.type = "text/css"; + link.rel = "stylesheet"; + link.href = requirejs.toUrl(name, 'css'); + document.getElementsByTagName("head")[0].appendChild(link); + }; + + /** + * Initialize extension + * + */ + var load_extension = function () { + // first, check which view we're in, in order to decide whether to load + var conf_sect; + if (Jupyter.notebook) { + // we're in notebook view + conf_sect = Jupyter.notebook.config; + } + else if (Jupyter.editor) { + // we're in file-editor view + conf_sect = new configmod.ConfigSection('notebook', {base_url: Jupyter.editor.base_url}); + conf_sect.load(); + } + else { + // we're some other view like dashboard, terminal, etc, so bail now + return; + } + + load_css('codemirror/addon/fold/foldgutter.css'); + /* change default gutter width */ + load_css( './foldgutter.css'); + + conf_sect.loaded + .then(function () { update_params(conf_sect.data); }) + .then(on_config_loaded); + + if (Jupyter.notebook) { + /* require our additional custom codefolding modes before initialising fully */ + requirejs(['./firstline-fold', './magic-fold', './blockcomment-fold'], function () { + if (Jupyter.notebook._fully_loaded) { + setTimeout(function () { + console.log('Codefolding: Wait for', params.init_delay, 'ms'); + initExistingCells(); + }, params.init_delay); + } + else { + events.one('notebook_loaded.Notebook', initExistingCells); + } + }); + } + else { + activate_cm_folding(Jupyter.editor.codemirror); + setTimeout(function () { + console.log('Codefolding: Wait for', params.init_delay, 'ms'); + Jupyter.editor.codemirror.refresh(); + }, params.init_delay); + } + }; + + return {load_ipython_extension : load_extension}; +}); diff --git a/.local/share/jupyter/nbextensions/codemirror_mode_extensions/main.js b/.local/share/jupyter/nbextensions/codemirror_mode_extensions/main.js new file mode 100644 index 0000000000000000000000000000000000000000..d960d1ffd2ab9e0556d2b96232f4e08df61c423a --- /dev/null +++ b/.local/share/jupyter/nbextensions/codemirror_mode_extensions/main.js @@ -0,0 +1,11 @@ +define(['codemirror/lib/codemirror'], function (CodeMirror) { + "use strict"; + return { + load_ipython_extension : function () { + CodeMirror.extendMode('octave', { + lineComment: '%', + fold: 'indent', + }); + } + }; +}); diff --git a/.local/share/jupyter/nbextensions/comment-uncomment/comment-uncomment.yaml b/.local/share/jupyter/nbextensions/comment-uncomment/comment-uncomment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..62bc0886fc841ed63c014e31f2708bbe286adb1c --- /dev/null +++ b/.local/share/jupyter/nbextensions/comment-uncomment/comment-uncomment.yaml @@ -0,0 +1,16 @@ +Type: IPython Notebook Extension +Compatibility: 4.x, 5.x +Name: Comment/Uncomment Hotkey +Main: main.js +Description: add new configurable hotkey binding to toggle comments +Icon: icon.png +Link: readme.md +Parameters: +- name: comment_uncomment_keybinding + description: keybinding for toggling comments + input_type: hotkey + default: alt-c +- name: comment_uncomment_indent + description: indent comment at current indent level instead of at beginning of line + default: false + input_type: checkbox diff --git a/.local/share/jupyter/nbextensions/comment-uncomment/main.js b/.local/share/jupyter/nbextensions/comment-uncomment/main.js new file mode 100644 index 0000000000000000000000000000000000000000..3aea80867b625bbf40c209166719c99401e79c05 --- /dev/null +++ b/.local/share/jupyter/nbextensions/comment-uncomment/main.js @@ -0,0 +1,63 @@ +// add new configurable hotkey binding to toggle comments + +define([ + 'base/js/namespace', +], function( + IPython +) { + "use strict"; + + // define default config parameter values + var params = { + comment_uncomment_keybinding : 'alt-c', + comment_uncomment_indent: false, + }; + + // updates default params with any specified in the server's config + var update_params = function() { + var config = IPython.notebook.config; + for (var key in params){ + if (config.data.hasOwnProperty(key) ){ + params[key] = config.data[key]; + } + } + }; + + var initialize = function () { + // update defaults + update_params(); + + // register actions with ActionHandler instance + var prefix = 'auto'; + var name = 'toggle-comment'; + var action = { + icon: 'fa-comment-o', + help : 'Toggle comments', + help_index : 'eb', + id : 'read_only_codecell', + handler : toggle_comment + }; + var action_full_name = IPython.keyboard_manager.actions.register(action, name, prefix); + + // define keyboard shortcuts + var edit_mode_shortcuts = {}; + edit_mode_shortcuts[params.comment_uncomment_keybinding] = action_full_name; + + // register keyboard shortcuts with keyboard_manager + IPython.notebook.keyboard_manager.edit_shortcuts.add_shortcuts(edit_mode_shortcuts); + }; + + var toggle_comment = function() { + var cm = IPython.notebook.get_selected_cell().code_mirror; + cm.toggleComment({ indent: params.comment_uncomment_indent }); + return false; + }; + + var load_ipython_extension = function () { + return IPython.notebook.config.loaded.then(initialize); + }; + + return { + load_ipython_extension : load_ipython_extension + }; +}); diff --git a/.local/share/jupyter/nbextensions/contrib_nbextensions_help_item/README.md b/.local/share/jupyter/nbextensions/contrib_nbextensions_help_item/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d4ce0987af19bbe98160699da6bffeac6b88290d --- /dev/null +++ b/.local/share/jupyter/nbextensions/contrib_nbextensions_help_item/README.md @@ -0,0 +1,6 @@ +Help menu entry +=============== + +The `contrib_nbextensions_help_item` is a tiny nbextension that just adds an +item to the notebook's help menu, pointing to the docs at readthedocs: +[jupyter_contrib_nbextensions.readthedocs.io](https://jupyter_contrib_nbextensions.readthedocs.io) diff --git a/.local/share/jupyter/nbextensions/datestamper/readme.md b/.local/share/jupyter/nbextensions/datestamper/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..494755112c96ef9b04c5e21b681e7e448c1be098 --- /dev/null +++ b/.local/share/jupyter/nbextensions/datestamper/readme.md @@ -0,0 +1,6 @@ +Datestamper +=========== + +Adds a toolbar button which pastes the current time & date into the current cell: + +![](icon.png) diff --git a/.local/share/jupyter/nbextensions/equation-numbering/button.png b/.local/share/jupyter/nbextensions/equation-numbering/button.png new file mode 100644 index 0000000000000000000000000000000000000000..08ed05aa4dca6a45599b231b7096d76ddc5a1b0d Binary files /dev/null and b/.local/share/jupyter/nbextensions/equation-numbering/button.png differ diff --git a/.local/share/jupyter/nbextensions/equation-numbering/main.js b/.local/share/jupyter/nbextensions/equation-numbering/main.js new file mode 100644 index 0000000000000000000000000000000000000000..6d4289ba0814cdb0ec7fc2d42e93c44225414c4d --- /dev/null +++ b/.local/share/jupyter/nbextensions/equation-numbering/main.js @@ -0,0 +1,39 @@ +// Copyright (c) IPython-Contrib Team. +// Distributed under the terms of the Modified BSD License. + +define([ + 'base/js/namespace', + 'jquery', + 'require', + 'notebook/js/textcell', + 'base/js/utils', +], function(Jupyter, $, requirejs, textcell, utils) { + "use strict"; + + var MathJax = window.MathJax; + + var load_ipython_extension = function() { + var btn_grp = Jupyter.toolbar.add_buttons_group([ + Jupyter.keyboard_manager.actions.register ({ + help : 'Reset equation numbering', + icon : 'fa-sort-numeric-asc', + handler: function () { + MathJax.Hub.Queue( + ["resetEquationNumbers", MathJax.InputJax.TeX], + ["PreProcess", MathJax.Hub], + ["Reprocess", MathJax.Hub] + ); + $('#reset_numbering').blur(); + } + }, 'reset-numbering', 'equation_numbering') + ]); + $(btn_grp).find('.btn').attr('id', 'reset_numbering'); + MathJax.Hub.Config({ + TeX: { equationNumbers: { autoNumber: "AMS" } } + }); + }; + + return { + load_ipython_extension : load_ipython_extension + }; +}); diff --git a/.local/share/jupyter/nbextensions/execute_time/ExecuteTime.css b/.local/share/jupyter/nbextensions/execute_time/ExecuteTime.css new file mode 100644 index 0000000000000000000000000000000000000000..4ad3c4b0fa83864d023b0be21f4e697a14d2b512 --- /dev/null +++ b/.local/share/jupyter/nbextensions/execute_time/ExecuteTime.css @@ -0,0 +1,6 @@ +.timing_area { + padding: 0 5px; + border: none; + border-top: 1px solid #CFCFCF; + font-size: 80%; +} diff --git a/.local/share/jupyter/nbextensions/execute_time/execution-timings-box.png b/.local/share/jupyter/nbextensions/execute_time/execution-timings-box.png new file mode 100644 index 0000000000000000000000000000000000000000..ea845ed14406a3b5788ab2e2f1c3079108019eef Binary files /dev/null and b/.local/share/jupyter/nbextensions/execute_time/execution-timings-box.png differ diff --git a/.local/share/jupyter/nbextensions/exercise/image.gif b/.local/share/jupyter/nbextensions/exercise/image.gif new file mode 100644 index 0000000000000000000000000000000000000000..0fe22308b600e50d9f51ebe6a7164475ddb81c4e Binary files /dev/null and b/.local/share/jupyter/nbextensions/exercise/image.gif differ diff --git a/.local/share/jupyter/nbextensions/exercise/readme.md b/.local/share/jupyter/nbextensions/exercise/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..54eb1d426e8e3714466df48fc3a7f8da683a9564 --- /dev/null +++ b/.local/share/jupyter/nbextensions/exercise/readme.md @@ -0,0 +1,52 @@ +Exercise +======== + +These are two extensions for Jupyter, for hiding/showing solutions cells. +They use the same approach and codebase and differ only by the type of +`cell widget` used the show/hide the solutions. The two extensions can be used +simultaneously. They require the `rubberband` extension to be installed and +enabled. + +The example below demonstrates some of the features of the exercise extensions. + +- First, an solution or "details" cell is created by (a) selecting two cells with the rubberband and (b) clicking on the menu-button [exercise extension] +- Second, the two next cells are selected using a keyboard shortcut, and a solution is created using the shortcut Alt-D [exercise2 extension] +- Third, the two solutions are expanded by clicking on the corresponding widgets +- Fourth, the solutions are removed by selecting them and clicking on the buttons in the toolbar. + +![](image.gif) + + +The extensions provide +---------------------- + +- a menubar button +- a cell widget -- A plus/minus button in `exercise` and a sliding checkbox in `exercise2`. + +The menubar button is devoted to the creation or removing of the solution. The solution consists in several consecutive cells that can be selected by the usual notebook multicell selection methods (e.g. *Shift-down* (select next) or *Shift-up* (select previous) keyboard shortcuts, or using the rubberband extension. + + +### Creating a solution + +Several cells being selected, pressing the menubar button adds a `cell widget` and hides the cells excepted the first one which serves as a heading cell. *Do not forget to keep the Shift key pressed down while clicking on the menu button +(otherwise selected cells will be lost)*. It is also possible to use a keyboard shortcut for creating the solution from selected cells: Alt-S for exercise extension and Alt-D for exercise2. + + +### Removing a solution + +If a solution heading (first) cell is selected, then clicking the menu bar button removes this solution and its solutions cells are shown. Using the keyboard shortcut has the same effect. + + +### Showing/hiding solution + +At creation of the solution, the solution cells are hidden. Clicking the `cell widget` toggles the hidden/shown state of the solution. + + +### Persistence + +The state of solutions, hidden or shown, is preserved and automatically restored at startup and on reload. + + +### Internals + +exercise and exercise2 add respectively a solution and solution2 metadata to solution cells, with for value the current state hidden/shown of the solution. For exercise, a div with the plus/minus character is prepended to the solution heading cell. For exercise2, a flex-wrap style is added to the solution heading cell and a checkbox widget, with some css styling, is appended to the cell. A solution[.2]_first metadada is also added to enable an easy detection of the first cell in an "exercise" and then allow several consecutive exercises. diff --git a/.local/share/jupyter/nbextensions/go_to_current_running_cell/README.md b/.local/share/jupyter/nbextensions/go_to_current_running_cell/README.md new file mode 100644 index 0000000000000000000000000000000000000000..067691526a2821ad8b0ab8e2f44b11c2ef30e26b --- /dev/null +++ b/.local/share/jupyter/nbextensions/go_to_current_running_cell/README.md @@ -0,0 +1,22 @@ +Go to Running Cell +================== + +This is an extension allows you to jump to the current running cell. You can also activate this functionality automatically, i.e., your view is always scolling to the current cell. + +Button: A button with eye icon that you can go to the first running cell. +![button](anchor.png) + +Keyboard shortcuts: +------------------- +__*Alt-I*__ (Jump to first running cell) +__*Meta-[*__ (Follow executing cell On) +__*Meta-]*__(Follow executing cell Off) + +Demo +---- +### Jump to first running cell +![button](jump_to_cell.gif) + +### Follow executing cell + +![button](auto_focus.gif) \ No newline at end of file diff --git a/.local/share/jupyter/nbextensions/go_to_current_running_cell/go_to_current_running_cell.yaml b/.local/share/jupyter/nbextensions/go_to_current_running_cell/go_to_current_running_cell.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4bfcb6ebe59be3a5ee894f846bb327dc5855fdb2 --- /dev/null +++ b/.local/share/jupyter/nbextensions/go_to_current_running_cell/go_to_current_running_cell.yaml @@ -0,0 +1,26 @@ +Type: Jupyter Notebook Extension +Name: Go to Current Running Cells +Description: Go to Running cell and always scroll into current running cell view +Link: README.md +Main: main.js +Compatibility: 4.x, 5.x + +Parameters: +- name: is_follow_cell + description: Activate follow executing cells, default behavior is false. + input_type: checkbox +- name: go_to_running_cell_shortcut + description: Go to first running cell + input_type: input + default: Alt-I +- name: follow_cell_on_shortcut + description: Enable following running cell + input_type: input + default: Alt-; +- name: follow_cell_off_shortcut + description: Disable following running cell + input_type: input + default: Alt-' +- name: button_icon + description: Button for go to first running cell + default: fa-anchor \ No newline at end of file diff --git a/.local/share/jupyter/nbextensions/go_to_current_running_cell/jump_to_cell.gif b/.local/share/jupyter/nbextensions/go_to_current_running_cell/jump_to_cell.gif new file mode 100644 index 0000000000000000000000000000000000000000..b26c08bdd324cffbb19627ae9284172311ce9363 Binary files /dev/null and b/.local/share/jupyter/nbextensions/go_to_current_running_cell/jump_to_cell.gif differ diff --git a/.local/share/jupyter/nbextensions/help_panel/help_panel.yaml b/.local/share/jupyter/nbextensions/help_panel/help_panel.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b70506151aa7c0dbf2187593dc1fc000463a7296 --- /dev/null +++ b/.local/share/jupyter/nbextensions/help_panel/help_panel.yaml @@ -0,0 +1,12 @@ +Type: IPython Notebook Extension +Compatibility: 3.x, 4.x, 5.x +Name: Help panel +Main: help_panel.js +Icon: icon.png +Link: readme.md +Description: Add a toolbar button to display a help panel showing shortcuts to the right side of the notebook +Parameters: +- name: help_panel_add_toolbar_button + description: add a toolbar button to open the shortcuts dialog/panel + input_type: checkbox + default: false diff --git a/.local/share/jupyter/nbextensions/hide_input_all/hide_input_all_hide.png b/.local/share/jupyter/nbextensions/hide_input_all/hide_input_all_hide.png new file mode 100644 index 0000000000000000000000000000000000000000..a15486a95ff60094c749e4154c92f2b566085210 Binary files /dev/null and b/.local/share/jupyter/nbextensions/hide_input_all/hide_input_all_hide.png differ diff --git a/.local/share/jupyter/nbextensions/highlight_selected_word/README.md b/.local/share/jupyter/nbextensions/highlight_selected_word/README.md new file mode 100644 index 0000000000000000000000000000000000000000..70e59a30ba19563c4aca0e8eb21aae1587ac2d5b --- /dev/null +++ b/.local/share/jupyter/nbextensions/highlight_selected_word/README.md @@ -0,0 +1,117 @@ +Highlight selected word +======================= + +[![Join the chat at https://gitter.im/jcb91/jupyter_highlight_selected_word](https://badges.gitter.im/jcb91/jupyter_highlight_selected_word.svg)](https://gitter.im/jcb91/jupyter_highlight_selected_word?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![GitHub issues](https://img.shields.io/github/issues/jcb91/jupyter_highlight_selected_word.svg?maxAge=3600)](https://github.com/jcb91/jupyter_highlight_selected_word/issues) + + +This nbextension highlights all instances of the selected word in either the +current cell's editor, or in all cells in the notebook. +It is based on the CodeMirror addon +[Match Highlighter](https://codemirror.net/demo/matchhighlighter.html), +but now uses its own codebase in order to permit matching across multiple +editors. + +There are a few configurable [options](#Options), all of which sit under the +config key `highlight_selected_word` in the `notebook` config section. + + +Options +------- + +Options are stored in the notebook section of the nbconfig. +The easiest way to configure these is using the +[jupyter_nbextensions_configurator](https://github.com/Jupyter-contrib/jupyter_nbextensions_configurator) +serverextension, but you can also configure them directly with a few lines of +python. + +The available options are: + +* `highlight_selected_word.highlight_across_all_cells` - if `true`, (default) + highlight matches across all cells. If `false`, only matches within the + currently selected cell will be highlighted. + +* `highlight_selected_word.code_cells_only` - Only apply highlights to editors + for Code cells, not, for example, Markdown or Raw cells + +* `highlight_selected_word.highlight_color` - Color used to highlight matching + words in the focused (active) cell + +* `highlight_selected_word.highlight_color_blurred` - Color used to highlight + matching words in blurred (non-active) cells + +* `highlight_selected_word.outlines_only` - Highlight words using just an + outline, rather than the background color. In contrast to the default + background-color highlight, the outline-only is also applied to the + currently-selected word + +* `highlight_selected_word.outline_width` - Width, in pixels, of the outline + used to highlight words when the outline-only setting (above) is selected. + Defaults to 1. + +* `highlight_selected_word.delay` - Wait time (in milliseconds) before + highlighting the matches + +* `highlight_selected_word.words_only` - If true, only highlight matches if the + selected text is a word + +* `highlight_selected_word.highlight_only_whole_words` - Only highlight matches + which are surrounded by non-word characters. This will use the token + `highlight_selected_word.show_token` to identify word characters, if it's + set, otherwise the regular expression `[\w$]` will be used. + +* `highlight_selected_word.show_token` - Token (regex) to identify word + characters, used to determine what to highlight when nothing is selected. + If blank, nothing is highlighted when nothing is selected. + This regex is also used to determine word boundaries for + `highlight_selected_word.highlight_only_whole_words`. + +* `highlight_selected_word.min_chars` - Minimum number of characters that must + be selected for the highlighting behavior to occur + +* `highlight_selected_word.use_toggle_hotkey` - Bind the + `highlight_selected_word.toggle` action to a hotkey. Defaults to `false`. + +* `highlight_selected_word.toggle_hotkey` - Which hotkey to bind to the + `highlight_selected_word.toggle` action (if set to use, see item above). + Defaults to `alt-h` + +* `highlight_selected_word.only_cells_in_scroll` - Only apply highlights to + editors which are visible in the scrolled view. This may offer performance + benefits for larger notebooks, but may be annoying if you're doing a lot of + scrolling :/ + +* `highlight_selected_word.scroll_min_delay` - Minimum delay in ms between + updating highlights on scrolling the notebook (used only if + `highlight_selected_word.only_cells_in_scroll` is `true`). + If set to zero, no update is done on scroll. + +* `highlight_selected_word.hide_selections_in_unfocussed` - Hide any text + selection in non-focussed cells. Otherwise, each cell can show a text + selection even when its editor is not focussed, which can be confused with + match highlights. + +For example, to set the delay to half a second, and limit highlighting to code +cells, we can use the following python snippet: + +```python +from notebook.services.config import ConfigManager +cm = ConfigManager() +cm.update('notebook', {'highlight_selected_word': { + 'delay': 500, + 'code_cells_only': True, +}}) +``` + + +Feedback +-------- + +If you have any feedback, or have any problems, please let me know by +[opening an issue](https://github.com/jcb91/jupyter_highlight_selected_word/issues/new) +at the project's +[github repository](https://github.com/jcb91/jupyter_highlight_selected_word). + +Thanks! + +Josh. diff --git a/.local/share/jupyter/nbextensions/highlight_selected_word/main.js b/.local/share/jupyter/nbextensions/highlight_selected_word/main.js new file mode 100644 index 0000000000000000000000000000000000000000..f290546e844450ae00211fe38fe4ca8cdafaf139 --- /dev/null +++ b/.local/share/jupyter/nbextensions/highlight_selected_word/main.js @@ -0,0 +1,419 @@ +/** + * Enable highlighting of matching words in cells' CodeMirror editors. + * + * This extension was adapted from the CodeMirror addon + * codemirror/addon/search/match-highlighter.js + */ + +define([ + 'require', + 'jquery', + 'base/js/namespace', + 'notebook/js/cell', + 'notebook/js/codecell', + 'codemirror/lib/codemirror', + // The mark-selection addon is need to ensure that the highlighting styles + // are *not* applied to the actual selection, as otherwise it can become + // difficult to see which is selected vs just highlighted. + 'codemirror/addon/selection/mark-selection' +], function ( + requirejs, + $, + Jupyter, + cell, + codecell, + CodeMirror +) { + 'use strict'; + + var Cell = cell.Cell; + var CodeCell = codecell.CodeCell; + + var mod_name = 'highlight_selected_word'; + var log_prefix = '[' + mod_name + ']'; + var menu_toggle_class = 'highlight_selected_word_toggle'; + + // Parameters (potentially) stored in server config. + // This object gets updated on config load. + var params = { + highlight_across_all_cells: true, + enable_on_load : true, + code_cells_only: false, + delay: 100, + words_only: false, + highlight_only_whole_words: true, + min_chars: 2, + show_token: '[\\w$]', + highlight_color: '#90EE90', + highlight_color_blurred: '#BBFFBB', + highlight_style: 'matchhighlight', + trim: true, + use_toggle_hotkey: false, + toggle_hotkey: 'alt-h', + outlines_only: false, + outline_width: 2, + only_cells_in_scroll: true, + scroll_min_delay: 100, + hide_selections_in_unfocussed: false, + }; + + // these are set on registering the action(s) + var action_names = { + toggle: '', + }; + + /** + * the codemirror matchHighlighter has a separate state object for each cm + * instance, but since our state is global over all cells' editors, we can + * use a single object for simplicity, and don't need to store options + * inside the state, since we have closure-level access to the params + * object above. + */ + var globalState = { + active: false, + timeout: null, // only want one timeout + scrollTimeout: null, + overlay: null, // one overlay suffices, as all cells use the same one + }; + + // define a CodeMirror option for highlighting matches in all cells + CodeMirror.defineOption("highlightSelectionMatchesInJupyterCells", false, function (cm, val, old) { + if (old && old != CodeMirror.Init) { + globalState.active = false; + // remove from all relevant, this can fail gracefully if not present + get_relevant_cells().forEach(function (cell, idx, array) { + cell.code_mirror.removeOverlay(mod_name); + }); + globalState.overlay = null; + clearTimeout(globalState.timeout); + globalState.timeout = null; + cm.off("cursorActivity", callbackCursorActivity); + cm.off("focus", callbackOnFocus); + } + if (val) { + if (cm.hasFocus()) { + globalState.active = true; + highlightMatchesInAllRelevantCells(cm); + } + else { + cm.on("focus", callbackOnFocus); + } + cm.on("cursorActivity", callbackCursorActivity); + } + }); + + /** + * The functions callbackCursorActivity, callbackOnFocus and + * scheduleHighlight are taken without major modification from cm's + * match-highlighter. + * The main difference is using our global state rather than + * match-highlighter's per-cm state, and a different highlighting function + * is scheduled. + */ + function callbackCursorActivity (cm) { + if (globalState.active || cm.hasFocus()) { + scheduleHighlight(cm); + } + } + + function callbackOnFocus (cm) { + // unlike cm match-highlighter, we *do* want to schedule a highight on + // focussing the editor + globalState.active = true; + scheduleHighlight(cm); + } + + function scheduleHighlight (cm) { + clearTimeout(globalState.timeout); + globalState.timeout = setTimeout(function () { highlightMatchesInAllRelevantCells(cm); }, params.delay); + } + + /** + * Adapted from cm match-highlighter's highlightMatches, but adapted to + * use our global state and parameters, plus work either for only the + * current editor, or multiple cells' editors. + */ + function highlightMatchesInAllRelevantCells (cm) { + var newOverlay = null; + + var re = params.show_token === true ? /[\w$]/ : params.show_token; + var from = cm.getCursor('from'); + if (!cm.somethingSelected() && params.show_token) { + var line = cm.getLine(from.line), start = from.ch, end = start; + while (start && re.test(line.charAt(start - 1))) { + --start; + } + while (end < line.length && re.test(line.charAt(end))) { + ++end; + } + if (start < end) { + newOverlay = makeOverlay(line.slice(start, end), re, params.highlight_style); + } + } + else { + var to = cm.getCursor("to"); + if (from.line == to.line) { + if (!params.words_only || isWord(cm, from, to)) { + var selection = cm.getRange(from, to); + if (params.trim) { + selection = selection.replace(/^\s+|\s+$/g, ""); + } + if (selection.length >= params.min_chars) { + var hasBoundary = params.highlight_only_whole_words ? (re instanceof RegExp ? re : /[\w$]/) : false; + newOverlay = makeOverlay(selection, hasBoundary, params.highlight_style); + } + } + } + } + + var siterect = document.getElementById('site').getBoundingClientRect(); + var viewtop = siterect.top, viewbot = siterect.bottom; + var cells = params.highlight_across_all_cells ? get_relevant_cells() : [ + $(cm.getWrapperElement()).closest('.cell').data('cell') + ]; + cells.forEach(function (cell, idx, array) { + // cm.operation to delay updating DOM until all work is done + cell.code_mirror.operation(function () { + cell.code_mirror.removeOverlay(mod_name); + if (newOverlay && is_in_view(cell.element[0], viewtop, viewbot)) { + cell.code_mirror.addOverlay(newOverlay); + } + }); + }); + } + + /** + * isWord, boundariesAround and makeOverlay come pretty much directly from + * Codemirror/addon/search/matchHighlighter + * since they don't use state or config values. + */ + function isWord (cm, from, to) { + var str = cm.getRange(from, to); + if (str.match(/^\w+$/) !== null) { + var pos, chr; + if (from.ch > 0) { + pos = {line: from.line, ch: from.ch - 1}; + chr = cm.getRange(pos, from); + if (chr.match(/\W/) === null) { + return false; + } + } + if (to.ch < cm.getLine(from.line).length) { + pos = {line: to.line, ch: to.ch + 1}; + chr = cm.getRange(to, pos); + if (chr.match(/\W/) === null) { + return false; + } + } + return true; + } + return false; + } + function boundariesAround (stream, re) { + return (!stream.start || !re.test(stream.string.charAt(stream.start - 1))) && + (stream.pos == stream.string.length || !re.test(stream.string.charAt(stream.pos))); + } + function makeOverlay (query, hasBoundary, style) { + return { + name: mod_name, + token: function (stream) { + if (stream.match(query) && + (!hasBoundary || boundariesAround(stream, hasBoundary))) { + return style; + } + stream.next(); + if (!stream.skipTo(query.charAt(0))) { + stream.skipToEnd(); + } + } + }; + } + + /** + * Returns true if part of elem is visible between viewtop & viewbot + */ + var is_in_view = function (elem, viewtop, viewbot) { + var rect = elem.getBoundingClientRect(); + // hidden elements show height 0 + return (rect.top < viewbot) && (rect.bottom > viewtop) && rect.height; + } + + /** + * Return an array of cells to which match highlighting is relevant, + * dependent on the code_cells_only parameter + */ + function get_relevant_cells () { + var cells = Jupyter.notebook.get_cells(); + return params.code_cells_only ? cells.filter(function (c) { return (c instanceof CodeCell); }) : cells; + } + + function add_menu_item () { + if ($('#view_menu').find('.' + menu_toggle_class).length < 1) { + var menu_item = $('
  • ') + .appendTo('#view_menu'); + var menu_link = $('') + .text('Highlight selected word') + .addClass(menu_toggle_class) + .attr({ + title: 'Highlight all instances of the selected word in the current editor', + href: '#', + }) + .on('click', function () { toggle_highlight_selected(); }) + .appendTo(menu_item); + $('') + .addClass('fa menu-icon pull-right') + .css({'margin-top': '-2px', 'margin-right': '-16px'}) + .prependTo(menu_link); + } + } + + var throttled_highlight = (function () { + var last, throttle_timeout; + return function throttled_highlight (cm) { + var now = Number(new Date()); + var do_it = function () { + last = Number(new Date()); + highlightMatchesInAllRelevantCells(cm); + }; + var remaining = last + params.scroll_min_delay - now; + if (last && remaining > 0) { + clearTimeout(throttle_timeout); + throttle_timeout = setTimeout(do_it, remaining); + } + else { + last = undefined; // so we will do it first time next streak + do_it(); + } + } + })(); + + function scroll_handler (evt) { + if (globalState.active && Jupyter.notebook.mode === 'edit' && globalState.overlay) { + // add overlay to cells now in view which don't already have it. + // Don't bother removing from those no longer in view, as it would just + // cause more work for the browser, without any benefit + var siterect = document.getElementById('site').getBoundingClientRect(); + get_relevant_cells().forEach(function (cell) { + var cm = cell.code_mirror; + if (is_in_view(cell.element, siterect.top, siterect.bot)) { + var need_it = !cm.state.overlays.some(function(ovr) { + return ovr.modeSpec.name === mod_name; }); + if (need_it) cm.addOverlay(globalState.overlay); + } + }); + } + } + + function toggle_highlight_selected (set_on) { + set_on = (set_on !== undefined) ? set_on : !params.enable_on_load; + // update config to make changes persistent + if (set_on !== params.enable_on_load) { + params.enable_on_load = set_on; + Jupyter.notebook.config.update({highlight_selected_word: {enable_on_load: set_on}}); + } + + // Change defaults for new cells: + var cm_conf = (params.code_cells_only ? CodeCell : Cell).options_default.cm_config; + cm_conf.highlightSelectionMatchesInJupyterCells = cm_conf.styleSelectedText = set_on; + + // And change any existing cells: + get_relevant_cells().forEach(function (cell, idx, array) { + cell.code_mirror.setOption('highlightSelectionMatchesInJupyterCells', set_on); + cell.code_mirror.setOption('styleSelectedText', set_on); + }); + // update menu class + $('.' + menu_toggle_class + ' > .fa').toggleClass('fa-check', set_on); + // bind/unbind scroll handler + $('#site')[ + (params.only_cells_in_scroll && params.scroll_min_delay > 0) ? 'on' : 'off' + ]('scroll', scroll_handler); + console.log(log_prefix, 'toggled', set_on ? 'on' : 'off'); + return set_on; + } + + function register_new_actions () { + action_names.toggle = Jupyter.keyboard_manager.actions.register({ + handler : function (env) { toggle_highlight_selected(); }, + help : "Toggle highlighting of selected word", + icon : 'fa-language', + help_index: 'c1' + }, 'toggle', mod_name); + } + + function bind_hotkeys () { + if (params.use_toggle_hotkey && params.toggle_hotkey) { + Jupyter.keyboard_manager.command_shortcuts.add_shortcut(params.toggle_hotkey, action_names.toggle); + Jupyter.keyboard_manager.edit_shortcuts.add_shortcut(params.toggle_hotkey, action_names.toggle); + } + } + + function insert_css () { + var css = [// in unselected cells, matches have blurred color + // in selected cells, we keep CodeMirror highlight for the actual selection to avoid confusion + '.edit_mode .unselected .CodeMirror .cm-matchhighlight {', + ' background-color: ' + params.highlight_color_blurred + ';', + '}', + + // in active cell, matches which are not the current selection have focussed color + '.edit_mode .CodeMirror.CodeMirror-focused :not(.CodeMirror-selectedtext).cm-matchhighlight {', + ' background-color: ' + params.highlight_color + ';', + '}', + + // in all cells, outline matches have blurred color + '.edit_mode .CodeMirror .cm-matchhighlight-outline {', + ' outline-style: solid;', + ' outline-width: ' + params.outline_width + 'px;', + ' outline-color: ' + params.highlight_color_blurred + ';', + '}', + + // in active cell, outline matches have focussed color + '.edit_mode .CodeMirror.CodeMirror-focused .cm-matchhighlight-outline {', + ' outline-color: ' + params.highlight_color + ';', + '}' + ].join('\n'); + + if (params.hide_selections_in_unfocussed) { + css += [ + // in unselected cells, selections which are not matches should have no background + '.unselected .CodeMirror :not(.cm-matchhighlight).CodeMirror-selected,', + '.unselected .CodeMirror :not(.cm-matchhighlight).CodeMirror-selectedtext {', + ' background: initial;', + '}', + ].join('\n'); + } + + $(' + + + + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +

    The highlighter extension:

      +
    • Firstable, the extension provides several toolbar buttons for highlighting a selected text within a markdown cell. Three different `color schemes' are provided, which can be easily customized in the \textit{stylesheet} highlighter.css. The last button enables to remove all highlightings in the current cell.
    • +
    • This works both when the cell is rendered and when the cell is in edit mode;
    • +
    • In both modes, it is possible to highlight formatted portions of text (In rendered mode, since the selected text loose its formatting, an heuristic is applied to find the best alignment with the actual text)
    • +
    • When no text is selected, the whole cell is highlighted;
    • +
    • The extension also provides two keyboard shortcuts (Alt-G and Alt-H) which fire the highlighting of the selected text.
    • +
    • Highlights can be preserved when exporting to html or to LaTeX -- details are provided in export_highlights
    • +
    +

    +

    Installation:

    The extension can be installed with the nice UI available on jupyter_contrib_nbextensions website, which also allows to enable/disable the extension.

    +

    You may also install the extension from the original repo: issue

    +
    jupyter nbextension install https://rawgit.com/jfbercher/small_nbextensions/master/highlighter.zip  --user
    +
    +

    at the command line.

    +

    Testing:

    Use a code cell with

    +
    %%javascript
    +require("base/js/utils").load_extensions("highlighter/highlighter")
    +
    +

    Automatic load

    You may also automatically load the extension for any notebook via

    +
    jupyter nbextension enable highlighter/highlighter
    +
    + +
    +
    +
    +
    +
    +
    In [2]:
    +
    +
    +
    %%javascript
    +require("base/js/utils").load_extensions("highlighter/highlighter")
    +
    + +
    +
    +
    + +
    +
    + + +
    + + +
    + +
    + +
    + +
    +
    + +
    +
    +
    + + diff --git a/.local/share/jupyter/nbextensions/highlighter/export_highlights.html b/.local/share/jupyter/nbextensions/highlighter/export_highlights.html new file mode 100644 index 0000000000000000000000000000000000000000..64dfcd57fc80b3a7c1997bc2280b4c643781d748 --- /dev/null +++ b/.local/share/jupyter/nbextensions/highlighter/export_highlights.html @@ -0,0 +1,372 @@ + + + +export_highlights + + + + + + + + + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +

    Exporting the notebook

    As suggested by @juhasch, it is interesting to keep the highlights when exporting the notebook to another format. We give and explain below some possibilities:

    + +
    +
    +
    +
    +
    +
    +
    +
    +

    Short version

      +
    • Html export:
      jupyter nbconvert FILE  --config JUPYTER_DATA_DIR/extensions/highlight_html_cfg.py
      +
      +
    • +
    • LaTeX export:
      jupyter nbconvert FILE  --config JUPYTER_DATA_DIR/extensions/highlight_latex_cfg.py
      +
      +where JUPYTER_DATA_DIR can be found from the output of
      jupyter --paths
      +
      +eg ~/.local/share/jupyter in my case. Seems to be c:\users\NAME\AppData\Roaming\jupyter under Windows.
    • +
    +

    Examples can be found here: initial notebook, html version, pdf version (after an additional LaTeX $\rightarrow$ pdf compilation).

    + +
    +
    +
    +
    +
    +
    +
    +
    +

    Html export

    This is quite easy. Actually, highlight formatting embedded in markdown cells is preserved while converting with the standard

    +
    jupyter nbconvert file.ipynb
    +
    +

    However, the css file is missing and must be added. Here we have several possibilities

    +
      +
    • Embed the css within the notebook. For that, consider the last cell of the present notebook. This code reads the css file highlighter.css in the extension directory and displays the corresponding style. So doing the <style> ...</style> section will be present in the cell output and interpreted by the web browser. Drawbacks of this solution is that user still have to execute this cell and that the this is not language agnostic.
    • +
    • Use a template file to link or include the css file during conversion. Such a file is provided as templates/highlighter.tpl. It was choosen here to include the css content in the produced html file rather than linking it. This avoids the necessity to keep the css file with the html files.

      +
        +
      • This works directly if the css resides in the same directory as the file the user is attempting to convert --thus requires the user to copy highlighter.css in the current directory. Then the conversion is simply
        jupyter nbconvert file.ipynb --template highlighter
        +
        +
      • +
      +
    • +
    • It still remains two problems with this approach. First, it can be annoying to have to systematically copy the css file in the current directory. Second, the data within the html tags is not converted (and thus markdown remains unmodified). A solution is to use a pair of preprocessor/postprocessor that modify the html tags and enable the subsequent markdown to html converter to operate on the included data. Also, a config file is provided which redefines the template path to enable direct inclusion of the css file in the extension directory. Unfortunately, it seems that the full path to the config file has to be provided. This file resides in the extensions subdirectory of the jupyter_data_dir. The path can be found by looking at the output of

      +
      jupyter --paths
      +
      +

      Then the command to issue for converting the notebook to html is

      +
      jupyter nbconvert FILE  --config JUPYTER_DATA_DIR/extensions/highlight_html_cfg.py
      +
      +
    • +
    +

    For instance

    +
    jupyter nbconvert tst_highlights.ipynb  --config ~/.local/share/jupyter/extensions/highlight_html_cfg.py
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    +

    LaTeX export

    This is a bit more complicated since the direct conversion removes all html formatting present in markdown cells. Thus use again a preprocessor which runs before the markdown $\rightarrow$ LaTeX conversion. In turn, it appears that we also need to postprocess the result.

    +

    Three LaTeX commands, namely highlighta, highlightb, highlightc, and three environments highlightA, highlightB, highlightC are defined. Highlighting html markup is then transformed into the corresponding LaTeX commands and the text for completely highlighted cells is put in the adequate LaTeX environment.

    +

    Pre and PostProcessor classes are defined in the file pp_highlighter.py located in the extensions directory. A LaTeX template, that includes the necessary packages and the definitions of commands/environments is provides as highlighter.tplx in the template directory. +The template inherits from article.ltx. For more complex scenarios, typically if the latex template file has be customized, the user shall modify its template or inherit from his base template rather than from article.

    +

    Finally, a config file fixes the different options for the conversion. Then the command to issue is simply

    +
    jupyter nbconvert FILE  --config JUPYTER_DATA_DIR/extensions/highlight_latex_cfg.py
    +
    +

    e.g.

    +
    jupyter nbconvert tst_highlights.ipynb  --config ~/.local/share/jupyter/extensions/highlight_latex_cfg.py
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    +

    Configuring paths

    For those who do not have taken the extension from the jupyter_contrib_nbextensions repository or have not configured extensions via its setup.py utility, a file set_paths.py is present in the extension directory (it is merely a verbatim copy of the relevant parts in setup.py). This file configure the paths to the templates and extension directories. It should be executed by something like

    +
    python3 set_paths.py
    +
    +

    Additionaly, you may also have to execute mv_paths.py if you installed from the original repo via jupyter nbextension install ..

    +
    python3 mv_paths.py
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    +

    Example for embedding the css within the notebook before conversion

    +
    +
    +
    +
    +
    +
    In [18]:
    +
    +
    +
    from IPython.core.display import display, HTML
    +from jupyter_core.paths import jupyter_config_dir, jupyter_data_dir
    +import os
    +csspath=os.path.join(jupyter_data_dir(),'nbextensions',
    +                       'highlighter','highlighter.css')
    +HTML('<style>'+open(csspath, "r").read()+'</style>')
    +
    + +
    +
    +
    + +
    +
    + + +
    Out[18]:
    + +
    + +
    + +
    + +
    +
    + +
    +
    +
    + + diff --git a/.local/share/jupyter/nbextensions/highlighter/export_highlights.ipynb b/.local/share/jupyter/nbextensions/highlighter/export_highlights.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..05ee5a16e5925d0cfb7324387c53c9af98e0ca34 --- /dev/null +++ b/.local/share/jupyter/nbextensions/highlighter/export_highlights.ipynb @@ -0,0 +1,194 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Exporting the notebook\n", + "\n", + "As suggested by @juhasch, it is interesting to keep the highlights when exporting the notebook to another format. We give and explain below some possibilities:" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Short version\n", + "- Html export:\n", + "```bash\n", + " jupyter nbconvert FILE --config JUPYTER_DATA_DIR/extensions/highlight_html_cfg.py \n", + "```\n", + "- LaTeX export:\n", + "```bash\n", + " jupyter nbconvert FILE --config JUPYTER_DATA_DIR/extensions/highlight_latex_cfg.py \n", + "```\n", + "where JUPYTER_DATA_DIR can be found from the output of\n", + "```bash\n", + " jupyter --paths\n", + "```\n", + "eg `~/.local/share/jupyter` in my case. Seems to be `c:\\users\\NAME\\AppData\\Roaming\\jupyter` under Windows. \n", + "\n", + "Examples can be found here: [initial notebook](tst_highlights.ipynb), [html version](tst_highlights.html), [pdf version](tst_highlights.pdf) (after an additional LaTeX $\\rightarrow$ pdf compilation). " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Html export\n", + "This is quite easy. Actually, highlight formatting embedded in markdown cells is preserved while converting with the standard\n", + "```bash\n", + "jupyter nbconvert file.ipynb\n", + "```\n", + "\n", + "However, the css file is missing and must be added. Here we have several possibilities\n", + "\n", + "- Embed the css *within* the notebook. For that, consider the last cell of the present notebook. This code reads the css file `highlighter.css` in the extension directory and displays the corresponding style. So doing the `` section will be present in the cell output and interpreted by the web browser. Drawbacks of this solution is that user still have to execute this cell and that the this is not language agnostic. \n", + "- Use a **template file** to link or include the css file during conversion. Such a file is provided as `templates/highlighter.tpl`. It was choosen here to *include* the css content in the produced html file rather than linking it. This avoids the necessity to keep the css file with the html files. \n", + " - This works directly if the css resides in the same directory as the file the user is attempting to convert --thus requires the user to copy `highlighter.css` in the current directory. Then the conversion is simply \n", + "```bash\n", + " jupyter nbconvert file.ipynb --template highlighter\n", + "```\n", + "\n", + "- It still remains two problems with this approach. First, it can be annoying to have to systematically copy the css file in the current directory. Second, the data within the html tags is not converted (and thus markdown remains unmodified). A solution is to use a pair of preprocessor/postprocessor that modify the html tags and enable the subsequent markdown to html converter to operate on the included data. Also, a config file is provided which redefines the template path to enable direct inclusion of the css file in the extension directory. Unfortunately, it seems that the *full path* to the config file has to be provided. This file resides in the extensions subdirectory of the jupyter_data_dir. The path can be found by looking at the output of\n", + "```bash\n", + " jupyter --paths\n", + "```\n", + "Then the command to issue for converting the notebook to html is\n", + "```bash\n", + " jupyter nbconvert FILE --config JUPYTER_DATA_DIR/extensions/highlight_html_cfg.py \n", + "```\n", + "\n", + "For instance\n", + "```bash\n", + "jupyter nbconvert tst_highlights.ipynb --config ~/.local/share/jupyter/extensions/highlight_html_cfg.py \n", + "```" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## LaTeX export\n", + "This is a bit more complicated since the direct conversion removes all html formatting present in markdown cells. Thus use again a **preprocessor** which runs before the markdown $\\rightarrow$ LaTeX conversion. In turn, it appears that we also need to postprocess the result. \n", + "\n", + "Three LaTeX commands, namely *highlighta, highlightb, highlightc*, and three environments *highlightA, highlightB, highlightC* are defined. Highlighting html markup is then transformed into the corresponding LaTeX commands and the text for completely highlighted cells is put in the adequate LaTeX environment. \n", + "\n", + "Pre and PostProcessor classes are defined in the file `pp_highlighter.py` located in the `extensions` directory. A LaTeX template, that includes the necessary packages and the definitions of commands/environments is provides as `highlighter.tplx` in the template directory. \n", + "The template inherits from `article.ltx`. For more complex scenarios, typically if the latex template file has be customized, the user shall modify its template or inherit from his base template rather than from article. \n", + "\n", + "Finally, a config file fixes the different options for the conversion. Then the command to issue is simply \n", + "```bash\n", + " jupyter nbconvert FILE --config JUPYTER_DATA_DIR/extensions/highlight_latex_cfg.py \n", + "```\n", + "e.g. \n", + "```bash\n", + "jupyter nbconvert tst_highlights.ipynb --config ~/.local/share/jupyter/extensions/highlight_latex_cfg.py \n", + "```\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configuring paths\n", + "\n", + "For those who do not have taken the extension from the `jupyter_contrib_nbextensions` repository or have not configured extensions via its `setup.py` utility, a file `set_paths.py` is present in the extension directory (it is merely a verbatim copy of the relevant parts in setup.py). This file configure the paths to the `templates` and `extension` directories. It should be executed by something like\n", + "```bash\n", + "python3 set_paths.py\n", + "```\n", + "Additionaly, you may also have to execute `mv_paths.py` if you installed from the original repo via `jupyter nbextension install ..`\n", + "```bash\n", + "python3 mv_paths.py\n", + "```" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example for embedding the css within the notebook before conversion" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from IPython.core.display import display, HTML\n", + "from jupyter_core.paths import jupyter_config_dir, jupyter_data_dir\n", + "import os\n", + "csspath=os.path.join(jupyter_data_dir(),'nbextensions',\n", + " 'highlighter','highlighter.css')\n", + "HTML('')" + ] + } + ], + "metadata": { + "interactive_sols": { + "cbx_id": 1 + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3+" + }, + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/.local/share/jupyter/nbextensions/highlighter/image.gif b/.local/share/jupyter/nbextensions/highlighter/image.gif new file mode 100644 index 0000000000000000000000000000000000000000..8a551ae16e8edd500a0aeb5082ce285747f82104 Binary files /dev/null and b/.local/share/jupyter/nbextensions/highlighter/image.gif differ diff --git a/.local/share/jupyter/nbextensions/highlighter/tst_highlights.html b/.local/share/jupyter/nbextensions/highlighter/tst_highlights.html new file mode 100644 index 0000000000000000000000000000000000000000..c354a71caf32400b0c28eff0139b208fcc25e154 --- /dev/null +++ b/.local/share/jupyter/nbextensions/highlighter/tst_highlights.html @@ -0,0 +1,218 @@ + + + +tst_highlights + + + + + + + + + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    +
    +
    +

    First cell

    In the first cell, we highlight some words using the different schemes provided.

    +

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus id lacus mauris. Etiam in dictum mauris. Morbi pharetra, mauris a feugiat consequat, est purus vulputate mauris, quis feugiat leo metus eu risus. Sed non luctus arcu. Donec eu ipsum justo. Praesent sit amet euismod orci. Nam eu turpis quis enim pulvinar blandit in eu justo. Vivamus nec libero ipsum. Nunc tempus, mi at vestibulum congue, lacus ante faucibus dolor, quis varius elit felis id ipsum. Vivamus at mi lorem. Integer quam massa, viverra et fermentum et, cursus faucibus nisl. Vestibulum sed est lacus. Morbi sit amet laoreet odio.

    + +
    +
    +
    +
    +
    +
    +
    +
    +

    +

    Second cell

    The second cell is completely highlighted.

    +

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus id lacus mauris. Etiam in dictum mauris. Morbi pharetra, mauris a feugiat consequat, est purus vulputate mauris, quis feugiat leo metus eu risus. Sed non luctus arcu. Donec eu ipsum justo. Praesent sit amet euismod orci. Nam eu turpis quis enim pulvinar blandit in eu justo. Vivamus nec libero ipsum. Nunc tempus, mi at vestibulum congue, lacus ante faucibus dolor, quis varius elit felis id ipsum. Vivamus at mi lorem. Integer quam massa, viverra et fermentum et, cursus faucibus nisl. Vestibulum sed est lacus. Morbi sit amet laoreet odio.

    + +
    +
    +
    +
    +
    + + diff --git a/.local/share/jupyter/nbextensions/highlighter/tst_highlights.pdf b/.local/share/jupyter/nbextensions/highlighter/tst_highlights.pdf new file mode 100644 index 0000000000000000000000000000000000000000..8df38f38a27ca8eda9ff32f0ca87c363405c25ad Binary files /dev/null and b/.local/share/jupyter/nbextensions/highlighter/tst_highlights.pdf differ diff --git a/.local/share/jupyter/nbextensions/highlighter/tst_highlights.tex b/.local/share/jupyter/nbextensions/highlighter/tst_highlights.tex new file mode 100644 index 0000000000000000000000000000000000000000..ec4cbc3d17f707f40b7462fc4488a0562cc4e000 --- /dev/null +++ b/.local/share/jupyter/nbextensions/highlighter/tst_highlights.tex @@ -0,0 +1,279 @@ + +% Default to the notebook output style + + +% Inherit from the specified cell style. + + + + + + +\documentclass{article} + + + + + \usepackage{graphicx} % Used to insert images + \usepackage{adjustbox} % Used to constrain images to a maximum size + \usepackage{color} % Allow colors to be defined + \usepackage{enumerate} % Needed for markdown enumerations to work + \usepackage{geometry} % Used to adjust the document margins + \usepackage{amsmath} % Equations + \usepackage{amssymb} % Equations + \usepackage{eurosym} % defines \euro + \usepackage[mathletters]{ucs} % Extended unicode (utf-8) support + \usepackage[utf8x]{inputenc} % Allow utf-8 characters in the tex document + \usepackage{fancyvrb} % verbatim replacement that allows latex + \usepackage{grffile} % extends the file name processing of package graphics + % to support a larger range + % The hyperref package gives us a pdf with properly built + % internal navigation ('pdf bookmarks' for the table of contents, + % internal cross-reference links, web links for URLs, etc.) + \usepackage{hyperref} + \usepackage{longtable} % longtable support required by pandoc >1.10 + \usepackage{booktabs} % table support for pandoc > 1.12.2 + +\usepackage{color} +\usepackage{soul} +\usepackage[framemethod=tikz]{mdframed} + + + + + \definecolor{orange}{cmyk}{0,0.4,0.8,0.2} + \definecolor{darkorange}{rgb}{.71,0.21,0.01} + \definecolor{darkgreen}{rgb}{.12,.54,.11} + \definecolor{myteal}{rgb}{.26, .44, .56} + \definecolor{gray}{gray}{0.45} + \definecolor{lightgray}{gray}{.95} + \definecolor{mediumgray}{gray}{.8} + \definecolor{inputbackground}{rgb}{.95, .95, .85} + \definecolor{outputbackground}{rgb}{.95, .95, .95} + \definecolor{traceback}{rgb}{1, .95, .95} + % ansi colors + \definecolor{red}{rgb}{.6,0,0} + \definecolor{green}{rgb}{0,.65,0} + \definecolor{brown}{rgb}{0.6,0.6,0} + \definecolor{blue}{rgb}{0,.145,.698} + \definecolor{purple}{rgb}{.698,.145,.698} + \definecolor{cyan}{rgb}{0,.698,.698} + \definecolor{lightgray}{gray}{0.5} + + % bright ansi colors + \definecolor{darkgray}{gray}{0.25} + \definecolor{lightred}{rgb}{1.0,0.39,0.28} + \definecolor{lightgreen}{rgb}{0.48,0.99,0.0} + \definecolor{lightblue}{rgb}{0.53,0.81,0.92} + \definecolor{lightpurple}{rgb}{0.87,0.63,0.87} + \definecolor{lightcyan}{rgb}{0.5,1.0,0.83} + + % commands and environments needed by pandoc snippets + % extracted from the output of `pandoc -s` + \providecommand{\tightlist}{% + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} + \DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}} + % Add ',fontsize=\small' for more characters per line + \newenvironment{Shaded}{}{} + \newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}} + \newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}} + \newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} + \newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} + \newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} + \newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} + \newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} + \newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}} + \newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}} + \newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} + \newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}} + \newcommand{\RegionMarkerTok}[1]{{#1}} + \newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} + \newcommand{\NormalTok}[1]{{#1}} + + % Define a nice break command that doesn't care if a line doesn't already + % exist. + \def\br{\hspace*{\fill} \\* } + % Math Jax compatability definitions + \def\gt{>} + \def\lt{<} + % Document parameters + \title{tst\_highlights} + + +\author{} + + + + % Pygments definitions + +\makeatletter +\def\PY@reset{\let\PY@it=\relax \let\PY@bf=\relax% + \let\PY@ul=\relax \let\PY@tc=\relax% + \let\PY@bc=\relax \let\PY@ff=\relax} +\def\PY@tok#1{\csname PY@tok@#1\endcsname} +\def\PY@toks#1+{\ifx\relax#1\empty\else% + \PY@tok{#1}\expandafter\PY@toks\fi} +\def\PY@do#1{\PY@bc{\PY@tc{\PY@ul{% + \PY@it{\PY@bf{\PY@ff{#1}}}}}}} +\def\PY#1#2{\PY@reset\PY@toks#1+\relax+\PY@do{#2}} + +\expandafter\def\csname PY@tok@mo\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} +\expandafter\def\csname PY@tok@sc\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} +\expandafter\def\csname PY@tok@nl\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.63,0.63,0.00}{##1}}} +\expandafter\def\csname PY@tok@nn\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}} +\expandafter\def\csname PY@tok@nv\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} +\expandafter\def\csname PY@tok@vc\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} +\expandafter\def\csname PY@tok@se\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.13}{##1}}} +\expandafter\def\csname PY@tok@gh\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}} +\expandafter\def\csname PY@tok@k\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} +\expandafter\def\csname PY@tok@kn\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} +\expandafter\def\csname PY@tok@sb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} +\expandafter\def\csname PY@tok@no\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.53,0.00,0.00}{##1}}} +\expandafter\def\csname PY@tok@gu\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.50,0.00,0.50}{##1}}} +\expandafter\def\csname PY@tok@o\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} +\expandafter\def\csname PY@tok@gd\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.63,0.00,0.00}{##1}}} +\expandafter\def\csname PY@tok@vi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} +\expandafter\def\csname PY@tok@s2\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} +\expandafter\def\csname PY@tok@il\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} +\expandafter\def\csname PY@tok@nd\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}} +\expandafter\def\csname PY@tok@cs\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}} +\expandafter\def\csname PY@tok@ge\endcsname{\let\PY@it=\textit} +\expandafter\def\csname PY@tok@go\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.53,0.53,0.53}{##1}}} +\expandafter\def\csname PY@tok@mb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} +\expandafter\def\csname PY@tok@sh\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} +\expandafter\def\csname PY@tok@w\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.73,0.73}{##1}}} +\expandafter\def\csname PY@tok@gr\endcsname{\def\PY@tc##1{\textcolor[rgb]{1.00,0.00,0.00}{##1}}} +\expandafter\def\csname PY@tok@ss\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} +\expandafter\def\csname PY@tok@cm\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}} +\expandafter\def\csname PY@tok@gs\endcsname{\let\PY@bf=\textbf} +\expandafter\def\csname PY@tok@kd\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} +\expandafter\def\csname PY@tok@bp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} +\expandafter\def\csname PY@tok@si\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}} +\expandafter\def\csname PY@tok@ni\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.60,0.60,0.60}{##1}}} +\expandafter\def\csname PY@tok@c\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}} +\expandafter\def\csname PY@tok@kr\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} +\expandafter\def\csname PY@tok@nb\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} +\expandafter\def\csname PY@tok@ow\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}} +\expandafter\def\csname PY@tok@s\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} +\expandafter\def\csname PY@tok@nf\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}} +\expandafter\def\csname PY@tok@mh\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} +\expandafter\def\csname PY@tok@na\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.49,0.56,0.16}{##1}}} +\expandafter\def\csname PY@tok@gp\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}} +\expandafter\def\csname PY@tok@gi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.63,0.00}{##1}}} +\expandafter\def\csname PY@tok@err\endcsname{\def\PY@bc##1{\setlength{\fboxsep}{0pt}\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}} +\expandafter\def\csname PY@tok@gt\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.27,0.87}{##1}}} +\expandafter\def\csname PY@tok@cp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.74,0.48,0.00}{##1}}} +\expandafter\def\csname PY@tok@kc\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} +\expandafter\def\csname PY@tok@sr\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}} +\expandafter\def\csname PY@tok@vg\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}} +\expandafter\def\csname PY@tok@kt\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.69,0.00,0.25}{##1}}} +\expandafter\def\csname PY@tok@nt\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} +\expandafter\def\csname PY@tok@ne\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.82,0.25,0.23}{##1}}} +\expandafter\def\csname PY@tok@sd\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} +\expandafter\def\csname PY@tok@c1\endcsname{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}} +\expandafter\def\csname PY@tok@s1\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}} +\expandafter\def\csname PY@tok@sx\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} +\expandafter\def\csname PY@tok@mf\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} +\expandafter\def\csname PY@tok@mi\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} +\expandafter\def\csname PY@tok@m\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}} +\expandafter\def\csname PY@tok@nc\endcsname{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}} +\expandafter\def\csname PY@tok@kp\endcsname{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}} + +\def\PYZbs{\char`\\} +\def\PYZus{\char`\_} +\def\PYZob{\char`\{} +\def\PYZcb{\char`\}} +\def\PYZca{\char`\^} +\def\PYZam{\char`\&} +\def\PYZlt{\char`\<} +\def\PYZgt{\char`\>} +\def\PYZsh{\char`\#} +\def\PYZpc{\char`\%} +\def\PYZdl{\char`\$} +\def\PYZhy{\char`\-} +\def\PYZsq{\char`\'} +\def\PYZdq{\char`\"} +\def\PYZti{\char`\~} +% for compatibility with earlier versions +\def\PYZat{@} +\def\PYZlb{[} +\def\PYZrb{]} +\makeatother + + + + + + + % Prevent overflowing lines due to hard-to-break entities + \sloppy + % Setup hyperref package + \hypersetup{ + breaklinks=true, % so long urls are correctly broken across lines + colorlinks=true, + urlcolor=blue, + linkcolor=darkorange, + citecolor=darkgreen, + } + % Slightly bigger margins than the latex defaults + + \geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in} + + + \newcommand{\highlighta}[1]{{\sethlcolor{yellow} \textcolor{red}{\hl{#1}}}} + \newcommand{\highlightb}[1]{{\sethlcolor{red} \textcolor{yellow}{\hl{#1}}}} + \newcommand{\highlightc}[1]{{\sethlcolor{green} \textcolor{yellow}{\hl{#1}}}} + \newenvironment{highlightA}{\begin{mdframed}[hidealllines=true,backgroundcolor=yellow!20]}{\end{mdframed}} + \newenvironment{highlightB}{\begin{mdframed}[hidealllines=true,backgroundcolor=red!20]}{\end{mdframed}} + \newenvironment{highlightC}{\begin{mdframed}[hidealllines=true,backgroundcolor=green!20]}{\end{mdframed}} + + +%\usepackage{foo} + + \begin{document} + + + \maketitle + + + + + \section{First cell}\label{first-cell} + +\highlighta{In the first cell, we highlight \emph{some words} +using the different schemes provided.} + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus id +lacus mauris. Etiam in dictum mauris. \highlightb{Morbi pharetra, +\textbf{mauris a feugiat consequat}, est purus vulputate mauris, quis +feugiat leo metus eu risus. Sed non luctus arcu.} Donec eu ipsum +justo. Praesent sit amet euismod orci. Nam eu turpis quis enim pulvinar +blandit in eu justo. Vivamus nec libero ipsum. Nunc tempus, mi at +vestibulum congue, lacus ante faucibus dolor, quis varius elit felis id +ipsum. \highlightc{Vivamus at mi lorem.} Integer quam massa, +viverra et fermentum et, cursus faucibus nisl. Vestibulum sed est lacus. +Morbi sit amet laoreet odio. + + \begin{highlightA} + +\section{Second cell}\label{second-cell} + +The second cell is completely highlighted. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus id +lacus mauris. Etiam in dictum mauris. Morbi pharetra, mauris a feugiat +consequat, \highlightb{est purus vulputate mauris,} quis +feugiat leo metus eu risus. Sed non luctus arcu. Donec eu ipsum justo. +Praesent sit amet euismod orci. Nam eu turpis quis enim pulvinar blandit +in eu justo. Vivamus nec libero ipsum. Nunc tempus, mi at vestibulum +congue, \highlightc{lacus ante faucibus dolor}, quis varius +elit felis id ipsum. Vivamus at mi lorem. Integer quam massa, viverra et +fermentum et, cursus faucibus nisl. Vestibulum sed est lacus. Morbi sit +amet laoreet odio. \end{highlightA} + + + % Add a bibliography block to the postdoc + + + + \end{document} diff --git a/.local/share/jupyter/nbextensions/hinterland/hinterland.js b/.local/share/jupyter/nbextensions/hinterland/hinterland.js new file mode 100644 index 0000000000000000000000000000000000000000..7fde256416cd71b290be1e696ffe6d6f840495fd --- /dev/null +++ b/.local/share/jupyter/nbextensions/hinterland/hinterland.js @@ -0,0 +1,194 @@ +define([ + 'module', + 'jquery', + 'base/js/namespace', + 'base/js/keyboard', + 'notebook/js/cell', + 'notebook/js/codecell', + 'notebook/js/completer', +], function ( + module, + $, + Jupyter, + keyboard, + cell, + codecell, + completer +) { + 'use strict'; + + var Cell = cell.Cell; + var CodeCell = codecell.CodeCell; + var Completer = completer.Completer; + + var log_prefix = '[' + module.id + ']'; + + // default config (updated on nbextension load) + var config = { + enable_at_start: true, + exclude_regexp: ':', + include_regexp: '', + tooltip_regexp: '\\(', + hint_delay: 20, + hint_inside_comments: false, + }; + // flag denoting whether hinting is enabled + var do_hinting; + + // ignore most specially-named keys + var specials = [ + keyboard.keycodes.enter, + keyboard.keycodes.esc, + keyboard.keycodes.backspace, + keyboard.keycodes.tab, + keyboard.keycodes.up, + keyboard.keycodes.down, + keyboard.keycodes.left, + keyboard.keycodes.right, + keyboard.keycodes.shift, + keyboard.keycodes.ctrl, + keyboard.keycodes.alt, + keyboard.keycodes.meta, + keyboard.keycodes.capslock, + keyboard.keycodes.space, + keyboard.keycodes.pageup, + keyboard.keycodes.pagedown, + keyboard.keycodes.end, + keyboard.keycodes.home, + keyboard.keycodes.insert, + keyboard.keycodes.delete, + keyboard.keycodes.numlock, + keyboard.keycodes.f1, + keyboard.keycodes.f2, + keyboard.keycodes.f3, + keyboard.keycodes.f4, + keyboard.keycodes.f5, + keyboard.keycodes.f6, + keyboard.keycodes.f7, + keyboard.keycodes.f8, + keyboard.keycodes.f9, + keyboard.keycodes.f10, + keyboard.keycodes.f11, + keyboard.keycodes.f12, + keyboard.keycodes.f13, + keyboard.keycodes.f14, + keyboard.keycodes.f15 + ]; + + /** + * copied from base/js/keyboard, since it isn't exported + * Return `true` if the event only contains modifiers keys. + * false otherwise + **/ + function only_modifier_event (event) { + var key = keyboard.inv_keycodes[event.which]; + return ( + (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) && + (key === 'alt'|| key === 'ctrl'|| key === 'meta'|| key === 'shift') + ); + } + + function patch_cell_keyevent () { + console.log(log_prefix, 'patching Cell.prototype.handle_codemirror_keyevent'); + var orig_handle_codemirror_keyevent = Cell.prototype.handle_codemirror_keyevent; + Cell.prototype.handle_codemirror_keyevent = function (editor, event) { + if (do_hinting && (this instanceof CodeCell) && !only_modifier_event(event)) { + // Tab completion. + this.tooltip.remove_and_cancel_tooltip(); + // don't attempt completion when selecting, or when using multicursor + if ( !editor.somethingSelected() && + editor.getSelections().length <= 1 && + !this.completer.visible && + specials.indexOf(event.keyCode) == -1) { + var cell = this; + // set a timeout to try to ensure that CodeMirror inserts + // the new key *before* the completion request happens + setTimeout(function () { + var cur = editor.getCursor(); + var pre_cursor = editor.getRange({ + line: cur.line, + ch: cur.ch - 1 + }, cur); + if ( pre_cursor !== '' && + (config.hint_inside_comments || editor.getTokenAt(cur).type !== "comment") && + (config.include_regexp.test(pre_cursor) || config.tooltip_regexp.test(pre_cursor)) && + !config.exclude_regexp.test(pre_cursor) ) { + if (config.tooltip_regexp.test(pre_cursor)) { + cell.tooltip.request(cell); + } + else { + cell.completer.startCompletion(); + cell.completer.autopick = false; + } + } + }, config.hint_delay); + } + } + return orig_handle_codemirror_keyevent.apply(this, arguments); + }; + } + + function set_hinterland_state (new_state) { + do_hinting = new_state; + $('.hinterland-toggle > .fa') + .toggleClass('fa-check', do_hinting); + console.log(log_prefix, 'continuous hinting', do_hinting ? 'on' : 'off'); + } + + function toggle_hinterland () { + set_hinterland_state(!do_hinting); + } + + function add_menu_item () { + if ($('#help_menu').find('.hinterland_toggle').length > 0) { + return; + } + var menu_item = $('
  • ') + .insertAfter('#keyboard_shortcuts'); + var menu_link = $('') + .text('Continuous hints') + .addClass('hinterland-toggle') + .attr('title', 'Provide continuous code hints') + .on('click', toggle_hinterland) + .appendTo(menu_item); + $('') + .addClass('fa menu-icon pull-right') + .prependTo(menu_link); + } + + function load_notebook_extension () { + + Jupyter.notebook.config.loaded.then(function on_success () { + $.extend(true, config, Jupyter.notebook.config.data.hinterland); + // special defaults: + // default include is taken from Completer, rather than the blank + if (config.include_regexp === '') { + config.include_regexp = Completer.reinvoke_re; + } + // now turn regexps loaded from config (which will be strings) into + // actual RegExp objects. + var regexp_names = ['exclude_regexp', 'include_regexp', 'tooltip_regexp']; + for (var ii=0; ii < regexp_names.length; ii++) { + if (config[regexp_names[ii]] === '') { + continue; + } + try { + config[regexp_names[ii]] = new RegExp(config[regexp_names[ii]]); + } + catch (err) { + console.warn(log_prefix, 'error parsing', regexp_names[ii] + ':', err); + } + } + }, function on_error (err) { + console.warn(log_prefix, 'error loading config:', err); + }).then(function on_success () { + patch_cell_keyevent(); + add_menu_item(); + set_hinterland_state(config.enable_at_start); + }); + } + + return { + load_ipython_extension : load_notebook_extension + }; +}); diff --git a/.local/share/jupyter/nbextensions/keyboard_shortcut_editor/readme_add_new_select_action.png b/.local/share/jupyter/nbextensions/keyboard_shortcut_editor/readme_add_new_select_action.png new file mode 100644 index 0000000000000000000000000000000000000000..ecc81b39ce204ae7d0107ba081af496be8c3d86a Binary files /dev/null and b/.local/share/jupyter/nbextensions/keyboard_shortcut_editor/readme_add_new_select_action.png differ diff --git a/.local/share/jupyter/nbextensions/keyboard_shortcut_editor/readme_shortcut_editor_blank.png b/.local/share/jupyter/nbextensions/keyboard_shortcut_editor/readme_shortcut_editor_blank.png new file mode 100644 index 0000000000000000000000000000000000000000..d80054017a2b79c926a34d39cdf7775af48cb9b9 Binary files /dev/null and b/.local/share/jupyter/nbextensions/keyboard_shortcut_editor/readme_shortcut_editor_blank.png differ diff --git a/.local/share/jupyter/nbextensions/livemdpreview/livemdpreview.yml b/.local/share/jupyter/nbextensions/livemdpreview/livemdpreview.yml new file mode 100644 index 0000000000000000000000000000000000000000..ed02488feef361d7ea854b0280c087a1ceaa8c9d --- /dev/null +++ b/.local/share/jupyter/nbextensions/livemdpreview/livemdpreview.yml @@ -0,0 +1,24 @@ +Type: Jupyter Notebook Extension +Compatibility: 4.x, 5.x +Name: Live Markdown Preview +Main: livemdpreview.js +Description: | + Live-preview the rendered output of markdown cells while editing their source. +Parameters: + +- name: livemdpreview.show_side_by_side + description: | + Show the input & output of markdown cells side-by-side while editing them. + Otherwise, the output appears immediately below the input while editing + input_type: checkbox + default: false + +- name: livemdpreview.timeout + description: | + Minimum time in ms between editing the markdown source & its output being + updated. This throttles the rate at which consecutive renderings will take + place. + input_type: number + default: 500 + min: 10 + step: 10 diff --git a/.local/share/jupyter/nbextensions/move_selected_cells/move_selected_cells.yaml b/.local/share/jupyter/nbextensions/move_selected_cells/move_selected_cells.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fef69c1504160b06c32a36371c09611603f19327 --- /dev/null +++ b/.local/share/jupyter/nbextensions/move_selected_cells/move_selected_cells.yaml @@ -0,0 +1,6 @@ +Type: IPython Notebook Extension +Name: Move selected cells +Description: Move selected cell*s* using keybaord shortcuts Alt-up and Alt-down +Link: README.md +Main: main.js +Compatibility: 4.x, 5.x diff --git a/.local/share/jupyter/nbextensions/navigation-hotkeys/main.js b/.local/share/jupyter/nbextensions/navigation-hotkeys/main.js new file mode 100644 index 0000000000000000000000000000000000000000..eeea36ca4245e65c273c622730e0adb2d4cd337d --- /dev/null +++ b/.local/share/jupyter/nbextensions/navigation-hotkeys/main.js @@ -0,0 +1,286 @@ +// add custom shortcuts + +define([ + 'base/js/namespace', + 'jquery' +], function(Jupyter, $) { + "use strict"; + + // define default values for config parameters + var params = { + toggle_enable_edit_shortcuts : true, + toggle_enable_command_shortcuts : true, + toggle_enable_esc_shortcut : true, + toggle_enable_enter_shortcuts : true, + }; + + // updates default params with any specified in the server's config + var update_params = function() { + var config = Jupyter.notebook.config; + for (var key in params){ + if (config.data.hasOwnProperty(key) ){ + params[key] = config.data[key]; + } + } + }; + + var add_command_shortcuts = { + 'home' : { + help : 'Go to top', + help_index : 'ga', + handler : function() { + Jupyter.notebook.select(0); + Jupyter.notebook.scroll_to_top(); + return false; + } + }, + + 'end' : { + help : 'Go to bottom', + help_index : 'ga', + handler : function() { + var ncells = Jupyter.notebook.ncells(); + Jupyter.notebook.select(ncells-1); + Jupyter.notebook.scroll_to_bottom(); + return false; + } + }, + + 'pageup' : { + help : 'Move cells page up', + help_index : 'gu', + handler : function() { + var wh = 0.6 * $(window).height(); + var cell = Jupyter.notebook.get_selected_cell(); + var h = 0; + /* loop until we have enough cells to span the size of the notebook window (= one page) */ + do { + h += cell.element.height(); + Jupyter.notebook.select_prev(); + cell = Jupyter.notebook.get_selected_cell(); + } while ( h < wh ); + var cp = cell.element.position(); + var sp = $('body').scrollTop(); + if ( cp.top < sp) { + Jupyter.notebook.scroll_to_cell(Jupyter.notebook.get_selected_index(), 0); + } + cell.focus_cell(); + return false; + } + }, + + 'pagedown' : { + help : 'Move cells page down', + help_index : 'gd', + handler : function() { + + /* jump to bottom if we are already in the last cell */ + var ncells = Jupyter.notebook.ncells(); + if ( Jupyter.notebook.get_selected_index()+1 == ncells) { + Jupyter.notebook.scroll_to_bottom(); + return false; + } + + var wh = 0.6*$(window).height(); + var cell = Jupyter.notebook.get_selected_cell(); + var h = 0; + + /* loop until we have enough cells to span the size of the notebook window (= one page) */ + do { + h += cell.element.height(); + Jupyter.notebook.select_next(); + cell = Jupyter.notebook.get_selected_cell(); + } while ( h < wh ); + cell.focus_cell(); + return false; + } + } + + }; + + var add_edit_shortcuts = { + 'alt-subtract' : { + help : 'Merge cell with previous cell', + help_index : 'eb', + handler : function() { + var i = Jupyter.notebook.get_selected_index(); + if (i > 0) { + var l = Jupyter.notebook.get_cell(i-1).code_mirror.lineCount(); + Jupyter.notebook.merge_cell_above(); + Jupyter.notebook.get_selected_cell().code_mirror.setCursor(l,0); + } + } + }, + 'alt-n' : { + help : 'Toggle line numbers', + help_index : 'xy', + handler : function() { + var cell = Jupyter.notebook.get_selected_cell(); + cell.toggle_line_numbers(); + return false; + } + }, + 'pagedown' : { + help : 'Page down', + help_index : 'xy', + handler : function() { + + var ic = Jupyter.notebook.get_selected_index(); + var cells = Jupyter.notebook.get_cells(); + var i, h=0; + for (i=0; i < ic; i ++) { + h += cells[i].element.height(); + } + var cur = cells[ic].code_mirror.getCursor(); + h += cells[ic].code_mirror.defaultTextHeight() * cur.line; + Jupyter.notebook.element.animate({scrollTop:h}, 0); + return false; + } + }, + 'pageup' : { + help : 'Page up', + help_index : 'xy', + handler : function() { + + var ic = Jupyter.notebook.get_selected_index(); + var cells = Jupyter.notebook.get_cells(); + var i, h=0; + for (i=0; i < ic; i ++) { + h += cells[i].element.height(); + } + var cur =cells[ic].code_mirror.getCursor(); + h += cells[ic].code_mirror.defaultTextHeight() * cur.line; + Jupyter.notebook.element.animate({scrollTop:h}, 0); + return false; + } + }, + 'ctrl-y' : { + help : 'Toggle markdown/code', + handler : function() { + var cell = Jupyter.notebook.get_selected_cell(); + var cur = cell.code_mirror.getCursor(); + if (cell.cell_type == 'code') { + Jupyter.notebook.command_mode(); + Jupyter.notebook.to_markdown(); + Jupyter.notebook.edit_mode(); + cell = Jupyter.notebook.get_selected_cell(); + cell.code_mirror.setCursor(cur); + } else if (cell.cell_type == 'markdown') { + Jupyter.notebook.command_mode(); + Jupyter.notebook.to_code(); + Jupyter.notebook.edit_mode(); + cell = Jupyter.notebook.get_selected_cell(); + cell.code_mirror.setCursor(cur); + } + return false; + } + } + }; + + var add_edit_enter_shortcuts = { + 'shift-enter' : { + help : 'Run cell and select next in edit mode', + help_index : 'bb', + handler : function() { + Jupyter.notebook.execute_cell_and_select_below(); + var rendered = Jupyter.notebook.get_selected_cell().rendered; + var ccell = Jupyter.notebook.get_selected_cell().cell_type; + if (rendered === false || ccell === 'code') Jupyter.notebook.edit_mode(); + return false; + } + }, + 'ctrl-enter' : { + help : 'Run selected cell stay in edit mode', + help_index : 'bb', + handler : function() { + var cell = Jupyter.notebook.get_selected_cell(); + var mode = cell.mode; + cell.execute(); + if (mode === "edit") Jupyter.notebook.edit_mode(); + return false; + } + } + }; + + var initialize = function() { + // Update default parameters + update_params(); + + var action; + var prefix = 'navigation_hotkeys'; + var action_name; + var action_name_spaces; + var action_full_name; + var all_commands_combined = [add_command_shortcuts, add_edit_enter_shortcuts, add_edit_shortcuts]; + + + // register all commands if one of the keybindings is not loaded so commands still available + for (let i = 0; i < all_commands_combined.length; i++){ + for (var key in all_commands_combined[i]){ + // check if the property/key is defined in the object itself, not in parent + if (all_commands_combined[i].hasOwnProperty(key)) { + action = all_commands_combined[i][key]; + action_name_spaces = all_commands_combined[i][key]['help']; + action_name = action_name_spaces.replace(/ /g,"-").toLowerCase(); + action_full_name = Jupyter.keyboard_manager.actions.register(action, action_name, prefix); + }; + }; + }; + + if (params.toggle_enable_command_shortcuts) { + for (var key in add_command_shortcuts) { + // check if the property/key is defined in the object itself, not in parent + if (add_command_shortcuts.hasOwnProperty(key)) { + action = add_command_shortcuts[key]; + action_name_spaces = add_command_shortcuts[key]['help']; + action_name = action_name_spaces.replace(/ /g,"-").toLowerCase(); + action_full_name = prefix + ":" + action_name; + Jupyter.keyboard_manager.command_shortcuts.add_shortcut( + key, action_full_name); + } + }; + if (params.toggle_enable_esc_shortcut) { + Jupyter.keyboard_manager.command_shortcuts.add_shortcut( + 'Esc','jupyter-notebook:enter-edit-mode'); + } + }; + + if (params.toggle_enable_edit_shortcuts) { + for (var key in add_edit_shortcuts) { + // check if the property/key is defined in the object itself, not in parent + if (add_edit_shortcuts.hasOwnProperty(key)) { + action = add_edit_shortcuts[key]; + action_name_spaces = add_edit_shortcuts[key]['help']; + action_name = action_name_spaces.replace(/ /g,"-").toLowerCase(); + action_full_name = prefix + ":" + action_name; + Jupyter.keyboard_manager.edit_shortcuts.add_shortcut(key, action_full_name); + } + }; + if (params.toggle_enable_enter_shortcuts) { + for (var key in add_edit_enter_shortcuts) { + // check if the property/key is defined in the object itself, not in parent + if (add_edit_enter_shortcuts.hasOwnProperty(key)) { + action = add_edit_enter_shortcuts[key]; + action_name_spaces = add_edit_enter_shortcuts[key]['help']; + action_name = action_name_spaces.replace(/ /g,"-").toLowerCase(); + action_full_name = prefix + ":" + action_name; + Jupyter.keyboard_manager.edit_shortcuts.add_shortcut( + key, action_full_name); + } + }; + }; + Jupyter.keyboard_manager.edit_shortcuts.add_shortcut( + 'alt-add','jupyter-notebook:split-cell-at-cursor'); + }; + + }; + + var load_ipython_extension = function() { + return Jupyter.notebook.config.loaded.then(initialize); + }; + + var extension = { + load_ipython_extension : load_ipython_extension + }; + return extension; +}); diff --git a/.local/share/jupyter/nbextensions/nbTranslate/languages.js b/.local/share/jupyter/nbextensions/nbTranslate/languages.js new file mode 100644 index 0000000000000000000000000000000000000000..cca62abbcf438fcdca3d03340255e61eef266da6 --- /dev/null +++ b/.local/share/jupyter/nbextensions/nbTranslate/languages.js @@ -0,0 +1,114 @@ +/** + * + * Generated from https://translate.google.com + * + * The languages that Google Translate supports (as of 5/15/16) alongside with their ISO 639-1 codes + * See https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes + */ + +var langs = { + 'auto': 'Automatic', + 'af': 'Afrikaans', + 'sq': 'Albanian', + 'ar': 'Arabic', + 'hy': 'Armenian', + 'az': 'Azerbaijani', + 'eu': 'Basque', + 'be': 'Belarusian', + 'bn': 'Bengali', + 'bs': 'Bosnian', + 'bg': 'Bulgarian', + 'ca': 'Catalan', + 'ceb': 'Cebuano', + 'ny': 'Chichewa', + 'zh-cn': 'Chinese Simplified', + 'zh-tw': 'Chinese Traditional', + 'co': 'Corsican', + 'hr': 'Croatian', + 'cs': 'Czech', + 'da': 'Danish', + 'nl': 'Dutch', + 'en': 'English', + 'eo': 'Esperanto', + 'et': 'Estonian', + 'tl': 'Filipino', + 'fi': 'Finnish', + 'fr': 'French', + 'fy': 'Frisian', + 'gl': 'Galician', + 'ka': 'Georgian', + 'de': 'German', + 'el': 'Greek', + 'gu': 'Gujarati', + 'ht': 'Haitian Creole', + 'ha': 'Hausa', + 'haw': 'Hawaiian', + 'iw': 'Hebrew', + 'hi': 'Hindi', + 'hmn': 'Hmong', + 'hu': 'Hungarian', + 'is': 'Icelandic', + 'ig': 'Igbo', + 'id': 'Indonesian', + 'ga': 'Irish', + 'it': 'Italian', + 'ja': 'Japanese', + 'jw': 'Javanese', + 'kn': 'Kannada', + 'kk': 'Kazakh', + 'km': 'Khmer', + 'ko': 'Korean', + 'ku': 'Kurdish (Kurmanji)', + 'ky': 'Kyrgyz', + 'lo': 'Lao', + 'la': 'Latin', + 'lv': 'Latvian', + 'lt': 'Lithuanian', + 'lb': 'Luxembourgish', + 'mk': 'Macedonian', + 'mg': 'Malagasy', + 'ms': 'Malay', + 'ml': 'Malayalam', + 'mt': 'Maltese', + 'mi': 'Maori', + 'mr': 'Marathi', + 'mn': 'Mongolian', + 'my': 'Myanmar (Burmese)', + 'ne': 'Nepali', + 'no': 'Norwegian', + 'ps': 'Pashto', + 'fa': 'Persian', + 'pl': 'Polish', + 'pt': 'Portuguese', + 'ma': 'Punjabi', + 'ro': 'Romanian', + 'ru': 'Russian', + 'sm': 'Samoan', + 'gd': 'Scots Gaelic', + 'sr': 'Serbian', + 'st': 'Sesotho', + 'sn': 'Shona', + 'sd': 'Sindhi', + 'si': 'Sinhala', + 'sk': 'Slovak', + 'sl': 'Slovenian', + 'so': 'Somali', + 'es': 'Spanish', + 'su': 'Sudanese', + 'sw': 'Swahili', + 'sv': 'Swedish', + 'tg': 'Tajik', + 'ta': 'Tamil', + 'te': 'Telugu', + 'th': 'Thai', + 'tr': 'Turkish', + 'uk': 'Ukrainian', + 'ur': 'Urdu', + 'uz': 'Uzbek', + 'vi': 'Vietnamese', + 'cy': 'Welsh', + 'xh': 'Xhosa', + 'yi': 'Yiddish', + 'yo': 'Yoruba', + 'zu': 'Zulu' +}; diff --git a/.local/share/jupyter/nbextensions/nbTranslate/mutils.js b/.local/share/jupyter/nbextensions/nbTranslate/mutils.js new file mode 100644 index 0000000000000000000000000000000000000000..6213923bb561245f19d641f53d95573a1c29fb4a --- /dev/null +++ b/.local/share/jupyter/nbextensions/nbTranslate/mutils.js @@ -0,0 +1,201 @@ +// Maths utilitary functions, +// adapted from latex_envs, see github.com/jfbercher/jupyter_latex_envs + +/**************************************************************************************************************** +* Series of elementary functions for manipulating nested environments +* needed to do that because standard regular expressions are not well suited for recursive things +****************************************************************************************************************/ +var OPENINGENV = '#!<', + OPENINGENVre = new RegExp(OPENINGENV, 'g'); +var CLOSINGENV = '#!>', + CLOSINGENVre = new RegExp(CLOSINGENV, 'g'); + +function envSearch(text, env_open, env_close) { + var reg = new RegExp(env_open + '[\\S\\s]*?' + env_close, 'gm'); + var start = text.match(reg); + var env_open_re = new RegExp(env_open); + var env_close_re = new RegExp(env_close); + var retval; + var r = ""; + if (typeof(start[0]) != 'undefined' && start[0] != null) { + var r = start[0].substr(1) + } + var out = env_open_re.test(r) //test if there exists an opening env at level +1 + //of the same kind inside + + if (out) { //in such case: replace the new opening at level +1 and the closing at level + var rnew = r.replace(env_close_re, CLOSINGENV).replace(env_open_re, OPENINGENV) + .replace(/\$\$/g,"!@$!@$") //last replace is because "$$" in the replacement string does not work + var text = text.replace(r, rnew).replace(/!@\$/g,"$"); + if (env_open_re.test(rnew)) { // if it remains nested envs, call the function again + retval = envSearch(text, env_open, env_close); + if (retval !== undefined) { + text = retval; + } + } + return text + } + return text +} + +function nestedEnvSearch(text, env_open, env_close) { + var regtest = new RegExp(env_open + '[\\S\\s]*?' + env_close); + var inmatches = text.match(regtest); + if (inmatches != null) { + for (i = 0; i < inmatches.length; i++) + inmatches[i] = inmatches[i].replace(/\*/g, '\\*') + var n = 0; + env_open = env_open.replace(/\([\\\+\S ]*?\)/g, function() { + return inmatches[++n] + }) + env_close = env_close.replace(/\\\d/g, function(x) { + return inmatches[parseInt(x.substr(1))] + }) + var output = envSearch(text, env_open, env_close) + var matches = output.match(env_open + '([\\S\\s]*?)' + env_close); + matches[0] = matches[0].replace(OPENINGENVre, env_open.replace('\\\\', '\\')) + .replace(CLOSINGENVre, env_close.replace('\\\\', '\\')) + matches[1] = matches[1].replace(OPENINGENVre, env_open.replace('\\\\', '\\')) + .replace(CLOSINGENVre, env_close.replace('\\\\', '\\')) + var result = [matches[0], inmatches[1], matches[1]] + for (i = 0; i < result.length; i++) + result[i] = result[i].replace(/\\\*\}/g, '*}') + return result; + } else return []; +} + + +function envReplaceApply(text, matches, replacement) { + var output; + if (matches.length != 0) { + if (replacement instanceof Function) { + output = text.replace(matches[0], + replacement(matches[0], matches[1], matches[2]) + .replace(/\$\$/g,"!@$!@$")).replace(/!@\$/g,"$") + //last line because "$$" in the replacement string does not work + } else if (typeof replacement == "string") { + output = text.replace(matches[0], replacement) + } + return output + } else { + return text; + } +} + +function nestedEnvReplace(text, env_open, env_close, replacement, flags) { + var list_of_matches = []; + var count = 200; //protection + var matches = nestedEnvSearch(text, env_open, env_close); + if (flags == undefined) { + return envReplaceApply(text, matches, replacement) + } else if (flags.indexOf('g') !== -1) { + var tmp_text = text; // tmp text + while (count-- > 0 & matches.length != 0) { + list_of_matches.push(matches[0]); + tmp_text = tmp_text.replace(matches[0], ""); //suppress from tmp_text + text = envReplaceApply(text, matches, replacement); + matches = nestedEnvSearch(tmp_text, env_open, env_close); + } + return text; + } else { + return text; + } +} + +var textEnvs = {'theorem':'theorem', 'lemma':'lemma', 'remark':'remark', +'example':'example', 'exercise':'exercise', 'corollary':'corollary', +'proposition':'proposition', 'definition':'definition','problem':'problem', +'proof':'proof', 'property':'property', 'itemize':'itemize', 'enumerate':'enumerate'} + +var textCmds = {'textbf':'textbf', 'textit':'textit', 'underline':'underline', +'texttt':'texttt', 'textem':'textem', 'emph':'emph'} +//label and ref not added because their content shall not be translated + +var OPENmath = 'mathid'//'\u003cmathid', + OPENmathRe = new RegExp(OPENmath, 'g'); +var CLOSEmath = ''//'\u003e', + CLOSEmathRe = new RegExp(CLOSEmath, 'g'); + +function removeMaths(text){ + var math=[]; + function replacement(m0,m1,m2) { + if (m1 in textEnvs){ + math.push('\\begin{'+m1+'}'); var id_beg = math.length; + math.push('\\end{'+m1+'}'); var id_end = math.length; + m2 = nestedEnvReplace(m2, '\\\\begin{(\\w+\\\*?)}', '\\\\end{\\1}', replacement, 'g') + return OPENmath + id_beg + CLOSEmath + m2 + OPENmath + id_end + CLOSEmath; + } + else if (m1 in textCmds){ + math.push('\\' + m1 + '{') + math.push('}') + return OPENmath + String(math.length - 1) + CLOSEmath + m2 + OPENmath + math.length + CLOSEmath; + } + else { + math.push(m0) + return OPENmath + math.length + CLOSEmath; + } + } + text = nestedEnvReplace(text, '\\\\begin{(\\w+\\\*?)}', '\\\\end{\\1}', replacement, 'g') + text = text.replace(/\\\[([\S\s]*?)\\\]/gm,replacement) + text = text.replace(/\\\(([\S\s]*?)\\\)/gm,replacement) + text = text.replace(/\$\$([\S\s]*?)\$\$/gm,replacement) + text = text.replace(/\$([\S\s]*?)\$/gm,replacement) + text = text.replace(/\\item/gm,replacement) + text = text.replace(/\\([\S]*?){([\S\s]*?)}/gm,replacement) //textcmd + return [math, text] +} + +function restoreMaths(math_and_text) { + var math = math_and_text[0]; + var text = math_and_text[1]; + var newtext; + var OPENmathUnicode = escape(OPENmath).replace(/%u([A-F0-9]{4})|%([A-F0-9]{2})/g, function(_, u, x) { return "\\\\u" + (u || '00' + x).toLowerCase() }); + var CLOSEmathUnicode = escape(CLOSEmath).replace(/%u([A-F0-9]{4})|%([A-F0-9]{2})/g, function(_, u, x) { return "\\\\u" + (u || '00' + x).toLowerCase() }); + var mathDetectRe = new RegExp(OPENmathUnicode+'\\s*?(\\d+)\\s*?'+CLOSEmathUnicode, 'gim'); + var cont = true; + while (cont) { + var newtext = text.replace(mathDetectRe, function(wholeMatch, n) { + return math[n - 1]; + }); + /*var newtext = newtext.replace(/\\u003cmathiid\s*?(\d+)\s*?\\u003e/gim, function(wholeMatch, n) { + return math[n - 1]; + }); */ + cont = text !== newtext; //recurse in text (possible nesting -- just one level) + text=newtext; + } + return text; +} + +var OPENhtml = 'htmlid' + OPENhtmlRe = new RegExp(OPENhtml, 'g'); +var CLOSEhtml = ''//'\u003e', + CLOSEhtmlRe = new RegExp(CLOSEhtml, 'g'); + +function removeHtml(text) { + var html = []; + function replacement(m0, m1) { + html.push(m0) + return OPENhtml + html.length + CLOSEhtml; + + } + text = text.replace(/<(\S[\S\s]*?)\S>/gm, replacement) + return [html, text] +} + + +function restoreHtml(html_and_text) { + var html = html_and_text[0]; + var text = html_and_text[1]; + var newtext; + var OPENhtmlUnicode = escape(OPENhtml).replace(/%u([A-F0-9]{4})|%([A-F0-9]{2})/g, function(_, u, x) { + return "\\\\u" + (u || '00' + x).toLowerCase() }); + var CLOSEhtmlUnicode = escape(CLOSEhtml).replace(/%u([A-F0-9]{4})|%([A-F0-9]{2})/g, function(_, u, x) { + return "\\\\u" + (u || '00' + x).toLowerCase() }); + var htmlDetectRe = new RegExp(OPENhtmlUnicode + '\\s*?(\\d+)\\s*?' + CLOSEhtmlUnicode, 'gim'); + text = text.replace(htmlDetectRe, function(wholeMatch, n) { + return html[n - 1]; + }); + + return text; +} + diff --git a/.local/share/jupyter/nbextensions/python-markdown/main.css b/.local/share/jupyter/nbextensions/python-markdown/main.css new file mode 100644 index 0000000000000000000000000000000000000000..72604f3e391a3454b842260ec22fa60c0e0b6847 --- /dev/null +++ b/.local/share/jupyter/nbextensions/python-markdown/main.css @@ -0,0 +1,4 @@ + +.notebook-trusted { + color: #555555; +} diff --git a/.local/share/jupyter/nbextensions/python-markdown/python-markdown.yaml b/.local/share/jupyter/nbextensions/python-markdown/python-markdown.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3e6663b97f50b8a65bdefc5df973ff488196e932 --- /dev/null +++ b/.local/share/jupyter/nbextensions/python-markdown/python-markdown.yaml @@ -0,0 +1,8 @@ +Type: IPython Notebook Extension +Name: Python Markdown +Description: Allows embedding Python-code in markdown cells +Link: readme.md +Icon: python-markdown.png +Main: main.js +Preprocessor: pymdpreprocessor.py +Compatibility: 4.x, 5.x diff --git a/.local/share/jupyter/nbextensions/rubberband/main.js b/.local/share/jupyter/nbextensions/rubberband/main.js new file mode 100644 index 0000000000000000000000000000000000000000..750bc9a6477da54f01abb5bae82138e971aa8d52 --- /dev/null +++ b/.local/share/jupyter/nbextensions/rubberband/main.js @@ -0,0 +1,237 @@ +// Select cells with a rubberband-selection using the mouse +// shift + mouse drag -> select only cells currently touched by rubberband +// alt+shift + mouse drag -> select all cells that were touched by rubberband + +define([ + 'base/js/namespace', + 'jquery', + 'base/js/events', + 'base/js/keyboard', + 'require' +], function(IPython, $, events, keyboard, requirejs) { + "use strict"; + + var scrollRange = 50; /* range on top and bottom where autoscroll starts */ + + var keycodes = keyboard.keycodes; + + var startX, startY; + var offsetY; + var isDragging = false; + var isRubberBandEnabled = false; + var isAddSelection = false; + var isScrolling = false; + var headerHeight; + + /* + * Test if a cell touched by a certain area + * + * @method isCellWithin + * @param cell + * @param left + * @param top + * @param width + * @param height + * + */ + var isCellWithin = function(cell,left,top,width,height){ + var cellpos = cell.element.position(); + var cellh = cell.element.height(); + var cellw = cell.element.width(); + if (cellpos.top === 0) + return false; // not visible + return ((cellpos.top+cellh) > top-offsetY && cellpos.top < top-offsetY+height + && cellpos.left+cellw > left && cellpos.left < left+width); + }; + + /** + * load css file and append to document + * + * @method load_css + * @param name {String} filenaame of CSS file + * + */ + var load_css = function (name) { + var link = document.createElement("link"); + link.type = "text/css"; + link.rel = "stylesheet"; + link.href = requirejs.toUrl(name); + document.getElementsByTagName("head")[0].appendChild(link); + }; + + + /** + * Clear existing selection + * + * @method clearSelection + * + */ + var clearSelection = function() { + var ncells = IPython.notebook.ncells(); + var cells = IPython.notebook.get_cells(); + + for(var i=0; i < ncells; i++){ + cells[i].unselect(); + } + }; + + + + function load_ipython_extension() { + /* + * Capture shift key - shift+mouse button will start rubberband selection + * + */ + $(document).keydown(function(event){ + if(event.keyCode === keycodes.shift && IPython.notebook.mode === "command"){ + isRubberBandEnabled = true + } + if(event.keyCode === keycodes.alt){ + isAddSelection = true + } + }); + + $(document).keyup(function(event){ + if(event.keyCode === keycodes.shift){ + isRubberBandEnabled = false + } + if(event.keyCode === keycodes.alt){ + isAddSelection = false + } + }); + + /* + * Start rubberband selection action + * + */ + $(document).mousedown(function(event){ + offsetY = $('#notebook').offset().top; + headerHeight = $('#header').height(); + if(isRubberBandEnabled) { + startX = event.pageX; + startY = event.pageY; + isDragging = true; + $("#dragmask").css( + { + 'left' : startX, + 'top' : startY, + 'width' : 0, + 'height' : 0 + } + + ).show(); + // prevent default behaviour of text selection + return false; + } else { + if (event.pageY-offsetY > 0) { + /* clear selection */ + var ncells = IPython.notebook.ncells(); + var cells = IPython.notebook.get_cells(); + var selected_idx = IPython.notebook.get_selected_index(); + for(var i=0; i < ncells; i++){ + if (i != selected_idx) cells[i].unselect(); + } + } + } + + }); + /* + * Rubberband dragging operation - select cells touched by rubberband + * + */ + $(document).mousemove(function(event){ + offsetY = $('#notebook').offset().top; + + if(isDragging === true){ + var left, top, width, height; + if(event.pageX>startX){ + left = startX; + width = event.pageX - startX; + } + else { + left = event.pageX; + width = startX - event.pageX; + } + if(event.pageY>startY){ + top = startY; + height = event.pageY - startY; + } + else { + top = event.pageY; + height = startY - event.pageY; + } + + var ncells = IPython.notebook.ncells(); + var cells = IPython.notebook.get_cells(); + var elheight = IPython.notebook.scroll_manager.element.height(); + var Yfromtop = event.clientY - headerHeight; + var scrollpos = IPython.notebook.scroll_manager.element.scrollTop(); + var scrolltime = 200; + if (Yfromtop < scrollRange && isScrolling === false) { + isScrolling = true; + IPython.notebook.scroll_manager.element.animate({scrollTop:scrollpos - 0.3*elheight}, scrolltime,"linear", function() { isScrolling = false }) + } + + if ( Yfromtop > elheight-scrollRange && isScrolling === false) { + isScrolling = true; + IPython.notebook.scroll_manager.element.animate({scrollTop: scrollpos + 0.3*elheight}, scrolltime,"linear", function() { isScrolling = false }) + } + + var selected_cells = IPython.notebook.get_selected_cells_indices() + var first = true; + for (var i=0; i i) delta = 1; + if (index < i) delta = -1; + IPython.notebook.select(i+delta, false); + }; + } + } + } + $("#dragmask").css( + { + 'left' : left, + 'top' : top, + 'width' : width, + 'height' : height + } + ) + } + }); + + /* + * End rubberband dragging operation + * + */ + $(document).mouseup(function(event){ + if(isDragging){ + isDragging = false; + $("#dragmask").hide(); + } + }); + load_css('./main.css'); + var rubberband_div = $('
    '); + $("#header").append(rubberband_div); + } + + /* expose functions to other extensions */ + var rubberband = { + load_ipython_extension : load_ipython_extension, + }; + return rubberband; +}); diff --git a/.local/share/jupyter/nbextensions/ruler/readme.md b/.local/share/jupyter/nbextensions/ruler/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..d815e1853cfe73f272b675f7a838f1a647feeaae --- /dev/null +++ b/.local/share/jupyter/nbextensions/ruler/readme.md @@ -0,0 +1,56 @@ +Ruler +===== + +This extension enables the Ruler CodeMirror feature + + +Configuration +------------- + +You can set the number of characters in the notebook extensions configration page or use the ConfigManager: + +```Python +from IPython.html.services.config import ConfigManager +ip = get_ipython() +cm = ConfigManager(parent=ip) +cm.update('notebook', {"ruler_column": [80]}) +``` + + +#### CSS patch #### + +Notebook versions from 4.3.0 through 5.1.0dev show up a bug in their CodeMirror +CSS padding which causes the ruler to be misplaced (see +[jupyter/notebook#2869](https://github.com/jupyter/notebook/issues/2869) +for details). +This nbextension introduces a css patch to attempt to correct this, but if it +causes problems for you, you can disable it by setting the `ruler_do_css_patch` +config key to `false`. + + +#### Multiple Rulers #### + +To specify multiple rulers, set the `ruler_column` to a list of values, for example + +```Python +cm.update('notebook', {"ruler_column": [10, 20, 30, 40, 50, 60, 70, 80]}) +``` + +A separate color and style can be specified for each ruler. + +```Python +cm.update('notebook', {"color": ["#000000", "#111111", "#222222", "#333333", "#444444", + "#555555", "#666666", "#777777", "#888888", "#999999"]}) +``` + +Creating a repeating pattern for either color or style is as simple as giving a list shorter than the total number of rulers + +```Python +cm.update('notebook', {"ruler_column": [10, 20, 30, 40, 50, 60, 70, 80]}) +cm.update('notebook', {"color": ["#FF0000", "#00FF00", "#0000FF"]}) +cm.update('notebook', {"style": ["dashed", "dotted"]}) +``` + +will result in `red, green, blue, red, green, blue, red, green, blue, red` and alternating `dashed, dotted` + +See [here](https://www.w3schools.com/cssref/pr_border-left_style.asp) for other line styles. diff --git a/.local/share/jupyter/nbextensions/runtools/demo.gif b/.local/share/jupyter/nbextensions/runtools/demo.gif new file mode 100644 index 0000000000000000000000000000000000000000..d906670d94ad392efddd35dc3f5d3e1e2b051f44 Binary files /dev/null and b/.local/share/jupyter/nbextensions/runtools/demo.gif differ diff --git a/.local/share/jupyter/nbextensions/runtools/gutter.css b/.local/share/jupyter/nbextensions/runtools/gutter.css new file mode 100644 index 0000000000000000000000000000000000000000..cebc4a99835ca52becb18ada654f0360b6ca4a1c --- /dev/null +++ b/.local/share/jupyter/nbextensions/runtools/gutter.css @@ -0,0 +1,3 @@ +.CodeMirror-cellstate { + width: 0.5em; +} diff --git a/.local/share/jupyter/nbextensions/runtools/icon.png b/.local/share/jupyter/nbextensions/runtools/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..1c44340568838ae33f0a563518f2e9a3ce421802 Binary files /dev/null and b/.local/share/jupyter/nbextensions/runtools/icon.png differ diff --git a/.local/share/jupyter/nbextensions/runtools/main.css b/.local/share/jupyter/nbextensions/runtools/main.css new file mode 100644 index 0000000000000000000000000000000000000000..2b3d987701b7d5b36ec5fc3efd85e54c86fd13f8 --- /dev/null +++ b/.local/share/jupyter/nbextensions/runtools/main.css @@ -0,0 +1,27 @@ +.icon-run-from:before{content:"\f10c\f04b"} +.icon-run-to:before{content:"\f04b\f10c"} +.icon-run-all:before{content:"\f04b\f01e"} +.icon-run-all-forced:before{content:"\f04b\f12a"} +.icon-run-marked:before{content:"\f04b\f08d"} + +.icon-mark-all:before{content:"\f111"} +.icon-mark-none:before{content:"\f10c"} +.icon-mark-toggle:before{content:"\f08d"} + +.icon-hide-input:before{content:"\f039\f068"} +.icon-hide-output:before{content:"\f02f\f068"} +.icon-show-input:before{content:"\f039\f067"} +.icon-show-output:before{content:"\f02f\f067"} + +#runtools-wrapper { + position: absolute; + width:340px; + top: 100px; + right: 0px; + float: right; + opacity: 1; + z-index: 100; + font-size: 12px; + font-weight: bold; + background-color: lightgrey; +} diff --git a/.local/share/jupyter/nbextensions/runtools/runtools.yaml b/.local/share/jupyter/nbextensions/runtools/runtools.yaml new file mode 100644 index 0000000000000000000000000000000000000000..995b80334ad2b8bd8b2f3f9d8c6922036a939d74 --- /dev/null +++ b/.local/share/jupyter/nbextensions/runtools/runtools.yaml @@ -0,0 +1,59 @@ +Type: IPython Notebook Extension +Name: Runtools +Description: Runtools provide a number of additional functions for working with code cells in the IPython notebook +Link: readme.md +Icon: icon.png +Main: main.js +Compatibility: 5.x +Parameters: +- name: runtools.run_cells_above + description: run cells above + input_type: hotkey + default: Alt-a +- name: runtools.run_cells_below + description: run cells below + input_type: hotkey + default: Alt-b +- name: runtools.toggle_marker + description: Toggle marker + input_type: hotkey + default: Alt-t +- name: runtools.mark_all_codecells + description: Mark all codecells + input_type: hotkey + default: Alt-m +- name: runtools.unmark_all_codecells + description: Unmark all codecells + input_type: hotkey + default: Alt-u +- name: runtools.run_marked_cells + description: run marked cells + input_type: hotkey + default: Alt-r +- name: runtools.stop_execution + description: stop execution + input_type: hotkey + default: Ctrl-c +- name: runtools.run_all_cells + description: run all cells + input_type: hotkey + default: Alt-x +- name: runtools.run_alls_cells_ignore_errors + description: run all cells - ignore errors + input_type: hotkey + default: Alt-f +- name: runtools.marked_color + description: | + Color for marking a codecell + default: '#20f224' + input_type: color +- name: runtools.scheduled_color + description: | + Color when a codecell is scheduled to be rund + default: '#00def0' + input_type: color +- name: runtools.run_color + description: | + Color while a codecell is being run + default: '#f30a2d' + input_type: color diff --git a/.local/share/jupyter/nbextensions/scratchpad/LICENSE b/.local/share/jupyter/nbextensions/scratchpad/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..e11323e4e259a9c535528bf18957f954af354a05 --- /dev/null +++ b/.local/share/jupyter/nbextensions/scratchpad/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2016, Min RK +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of nbextension-scratchpad nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/.local/share/jupyter/nbextensions/scroll_down/icon.png b/.local/share/jupyter/nbextensions/scroll_down/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..5dd365176140fd449fa4ce7ef43f2e91af8bc8ea Binary files /dev/null and b/.local/share/jupyter/nbextensions/scroll_down/icon.png differ diff --git a/.local/share/jupyter/nbextensions/scroll_down/main.js b/.local/share/jupyter/nbextensions/scroll_down/main.js new file mode 100644 index 0000000000000000000000000000000000000000..546b8e345a6d67e81fc345365e52e0ba9b5149f5 --- /dev/null +++ b/.local/share/jupyter/nbextensions/scroll_down/main.js @@ -0,0 +1,57 @@ +define([ + 'jquery', + 'base/js/namespace', +], function ( + $, + Jupyter +) { + 'use strict'; + + var params = { + scrollDownIsEnabled: false + }; + + var initialize = function () { + $.extend(true, params, Jupyter.notebook.config.data); + setButtonColor(); + }; + + function toggleScrollDown() { + params.scrollDownIsEnabled = !params.scrollDownIsEnabled; + Jupyter.notebook.config.update(params); + setButtonColor(); + } + + function setButtonColor() { + $("#toggle_scroll_down").toggleClass('active', params.scrollDownIsEnabled); + } + + function load_extension() { + $(Jupyter.toolbar.add_buttons_group([ + Jupyter.keyboard_manager.actions.register({ + help : 'toggle automatic scrolling down', + icon : 'fa-angle-double-down ', + handler: toggleScrollDown + }, 'toggle-auto-scroll-down', 'scroll_down') + ])).find('.btn').attr('id', 'toggle_scroll_down'); + + console.log("[ScrollDown] is loaded"); + + // the event was renamed from 'resize' to 'resizeOutput' in + // https://github.com/jupyter/notebook/commit/b4928d481abd9f7cd996fd4b24078a55880d21e6 + $(document).on("resize resizeOutput", ".output", function () { + if (!params.scrollDownIsEnabled) return; + var output = $(this); + setTimeout(function () { + output.scrollTop(output.prop("scrollHeight")); + }, 0); + }); + + return Jupyter.notebook.config.loaded.then(initialize); + } + + return { + load_jupyter_extension: load_extension, + load_ipython_extension: load_extension + }; +}); diff --git a/.local/share/jupyter/nbextensions/scroll_down/readme.md b/.local/share/jupyter/nbextensions/scroll_down/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..66b51115a6b54852d14880c5ac45777e57b010d7 --- /dev/null +++ b/.local/share/jupyter/nbextensions/scroll_down/readme.md @@ -0,0 +1,13 @@ +# ScrollDown + +When enabled, this nbextension scrolls cells' outputs down automatically as +they are enlarged. It can be enabled and disabled using the toolbar button: + +![](icon.png) + + +Options +------- + +The enabled status is toggleable with the toolbar button, which sets the option +option `scrollDownIsEnabled` in the notebook config section. diff --git a/.local/share/jupyter/nbextensions/snippets/main.js b/.local/share/jupyter/nbextensions/snippets/main.js new file mode 100644 index 0000000000000000000000000000000000000000..e0babac609ab1782bc0bdec058c37faff0c50180 --- /dev/null +++ b/.local/share/jupyter/nbextensions/snippets/main.js @@ -0,0 +1,70 @@ +// Code cell snippets + +define([ + 'jquery', + 'base/js/namespace', + 'base/js/dialog' +], function( + $, + Jupyter, + dialog +) { + "use strict"; + + var initialize = function () { + var dropdown = $("").attr("id", "snippet_picker") + .css("margin-left", "0.75em") + .attr("class", "form-control select-xs") + .change(insert_cell); + Jupyter.toolbar.element.append(dropdown); + }; + + // will be called when the nbextension is loaded + function load_extension() { + Jupyter.notebook.config.loaded.then(initialize); // trigger loading config parameters + + $.getJSON(Jupyter.notebook.base_url+"nbextensions/snippets/snippets.json", function(data) { + // Add the header as the top option, does nothing on click + var option = $("") + .attr("id", "snippet_header") + .text("Snippets"); + $("select#snippet_picker").append(option); + + // Add options for each code snippet in the snippets.json file + $.each(data['snippets'], function(key, snippet) { + var option = $("") + .attr("value", snippet['name']) + .text(snippet['name']) + .attr("code", snippet['code'].join('\n')); + $("select#snippet_picker").append(option); + }); + }) + .error(function(jqXHR, textStatus, errorThrown) { + // Add an error message if the JSON fails to load + var option = $("") + .attr("value", 'ERROR') + .text('Error: failed to load snippets!') + .attr("code", ""); + $("select#snippet_picker").append(option); + }); + + }; + + var insert_cell = function() { + var selected_snippet = $("select#snippet_picker").find(":selected"); + + if (selected_snippet.attr("name") != 'header') { + var code = selected_snippet.attr("code"); + var new_cell = Jupyter.notebook.insert_cell_above('code'); + new_cell.set_text(code); + new_cell.focus_cell(); + + $("option#snippet_header").prop("selected",true); + } + }; + + // return public methods + return { + load_ipython_extension : load_extension + }; +}); diff --git a/.local/share/jupyter/nbextensions/snippets/snippets.json b/.local/share/jupyter/nbextensions/snippets/snippets.json new file mode 100644 index 0000000000000000000000000000000000000000..5913adbcfae7a201c771429e426ba2ec7449679e --- /dev/null +++ b/.local/share/jupyter/nbextensions/snippets/snippets.json @@ -0,0 +1,14 @@ +{ + "snippets" : [ + { + "name" : "example", + "code" : [ + "# This is an example snippet!", + "# To create your own, add a new snippet block to the", + "# snippets.json file in your jupyter nbextensions directory:", + "# /nbextensions/snippets/snippets.json", + "import this" + ] + } + ] +} diff --git a/.local/share/jupyter/nbextensions/snippets_menu/config.yaml b/.local/share/jupyter/nbextensions/snippets_menu/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..033311fefc4e6a30b6e90f83c12649c851f5c0fc --- /dev/null +++ b/.local/share/jupyter/nbextensions/snippets_menu/config.yaml @@ -0,0 +1,123 @@ +Type: Jupyter Notebook Extension +Name: Snippets Menu +Link: readme.md +Description: | + Add a customizable menu item to insert code and markdown snippets. + Comes with extensive defaults for popular python modules, including fairly + complete listings of many important functions and constants, to save + searching through documentation. +Main: main.js +Icon: thumbnail.png +Compatibility: 4.x, 5.x +Parameters: + +- name: snippets.insert_as_new_cell + description: "Insert snippets as new cells, rather than at cursor inside current cell" + input_type: checkbox + default: false + +- name: snippets.include_custom_menu + description: "Include custom menu content parsed from JSON string below" + input_type: checkbox + default: false + +- name: snippets.custom_menu_content + description: | + JSON string parsed to define custom menus (only used if the option above is + checked) + input_type: textarea + default: | + { + "name" : "My favorites", + "sub-menu" : [ + { + "name" : "Menu item text", + "snippet" : ["import something", + "", + "new_command(3.14)", + "other_new_code_on_new_line('with a string!')", + "stringy(\"if you need them, escape double quotes with a single backslash\")", + "backslashy('This \\ appears as just one backslash in the output')", + "backslashy2('Here \\\\ are two backslashes')"] + }, + { + "name" : "TeX can be written in menu labels $\\alpha_W e\\int_0 \\mu \\epsilon$", + "snippet" : ["another_new_command(2.78)"] + } + ] + } + +- name: snippets.sibling_selector + description: | + A JQuery selector for a sibling element next to whose parent element the + new menu(s) will be inserted. Other suitable examples include '#file_menu', + '#edit_menu', '#view_menu', '#insert_menu', '#cell_menu', and + '#kernel_menu'. To append the new menu as a submenu to the 'insert' menu + itself, you could use '#insert_menu>:last-child'. + input_type: text + default: '#help_menu' + +- name: snippets.insert_before_sibling + description: | + Insert the new menu(s) before their sibling (the default value of false + means they are inserted after the sibling) + input_type: checkbox + default: false + +- name: snippets.top_level_submenu_goes_left + description: | + Snippets menus are often quite big, and positioned at the right side of the + menu bar, so by default they open to the left of the menu. Set this to + false to get them to open to the right as normal. + input_type: checkbox + default: true + +- name: snippets.include_submenu.numpy + description: "Include numpy sub-menu" + input_type: checkbox + default: true + +- name: snippets.include_submenu.scipy + description: "Include scipy sub-menu" + input_type: checkbox + default: true + +- name: snippets.include_submenu.matplotlib + description: "Include matplotlib sub-menu" + input_type: checkbox + default: true + +- name: snippets.include_submenu.sympy + description: "Include sympy sub-menu" + input_type: checkbox + default: true + +- name: snippets.include_submenu.pandas + description: "Include pandas sub-menu" + input_type: checkbox + default: true + +- name: snippets.include_submenu.astropy + description: "Include astropy sub-menu" + input_type: checkbox + default: true + +- name: snippets.include_submenu.h5py + description: "Include h5py sub-menu" + input_type: checkbox + default: true + +- name: snippets.include_submenu.numba + description: "Include numba sub-menu" + input_type: checkbox + default: true + +- name: snippets.include_submenu.python + description: "Include python sub-menu" + input_type: checkbox + default: true + +- name: snippets.include_submenu.markdown + description: "Include markdown sub-menu" + input_type: checkbox + default: true diff --git a/.local/share/jupyter/nbextensions/snippets_menu/screenshot2.png b/.local/share/jupyter/nbextensions/snippets_menu/screenshot2.png new file mode 100644 index 0000000000000000000000000000000000000000..63291f28557bf6840145ac091aafab94476730fb Binary files /dev/null and b/.local/share/jupyter/nbextensions/snippets_menu/screenshot2.png differ diff --git a/.local/share/jupyter/nbextensions/snippets_menu/snippets_submenu_markdown.js b/.local/share/jupyter/nbextensions/snippets_menu/snippets_submenu_markdown.js new file mode 100644 index 0000000000000000000000000000000000000000..163483fe858250389a25c800e54526646ad6c0cd --- /dev/null +++ b/.local/share/jupyter/nbextensions/snippets_menu/snippets_submenu_markdown.js @@ -0,0 +1,110 @@ +define({ + 'name' : 'Markdown', + 'sub-menu' : [ + { + 'name' : 'Documentation', + 'external-link' : 'https://help.github.com/articles/github-flavored-markdown/', + }, + '---', + + { + 'name' : 'Insert itemized list', + 'snippet' : [ + '* One', + ' - Sublist', + ' - This', + ' - Sublist', + ' - That', + ' - The other thing', + '* Two', + ' - Sublist', + '* Three', + ' - Sublist', + ], + }, + + { + 'name' : 'Insert enumerated list', + 'snippet' : [ + '1. Here we go', + ' 1. Sublist', + ' 2. Sublist', + '2. There we go', + '3. Now this', + ], + }, + + { + 'name' : 'Insert table', + 'snippet' : [ + '', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + '
    Header 1Header 2
    row 1, cell 1row 1, cell 2
    row 2, cell 1row 2, cell 2
    ', + ], + }, + + { + 'name' : 'Insert local image', + 'snippet' : [ + '', + ], + }, + + { + 'name' : 'Insert local video', + 'snippet' : [ + '