Giter VIP home page Giter VIP logo

ipython_extensions's Introduction

Miscellaneous IPython and Jupyter extensions

These extensions typically target master of IPython and/or Jupyter, so may not always work on the latest stable releases.

You can install each extension individually, via copy, download, or symlink (below):

ln -s $(pwd)/extensions/* $(ipython locate)/extensions
ln -s $(pwd)/nbextensions/* $(ipython locate)/nbextensions

or you can link the extension directories into your IPython directories (what I do):

ln -s $(pwd)/extensions $(ipython locate)/extensions
ln -s $(pwd)/nbextensions $(ipython locate)/nbextensions

Gist

Add a gist button to the notebook toolbar:

$ jupyter nbextension install https://rawgithub.com/minrk/ipython_extensions/master/nbextensions/gist.js
$ jupyter nbextension enable gist

Table of Contents

Generates floating table of contents inside your notebook from the heading cells. Adds a button to the toolbar to toggle the floating table of contents.

install the extension:

$ jupyter nbextension install --user https://rawgithub.com/minrk/ipython_extensions/master/nbextensions/toc.js
$ curl -L https://rawgithub.com/minrk/ipython_extensions/master/nbextensions/toc.css > $(jupyter --data-dir)/nbextensions/toc.css
$ jupyter nbextension enable toc

Write and execute

This IPython Notebook magic writes the content of the cell to a specified .py file before executing it. An identifier can be used when writing to the file, thus making it possible to overwrite previous iterations of the same code block. The use case for this extension is to export selected code from a Notebook for reuse through a .py file.

To install the extension use:

%install_ext https://raw.githubusercontent.com/minrk/ipython_extensions/master/extensions/writeandexecute.py

Then load it with

%load_ext writeandexecute

ipython_extensions's People

Contributors

andreas-h avatar bryant1410 avatar dekstop avatar flothesof avatar fperez avatar jankatins avatar magican avatar minrk avatar rabernat avatar videlec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ipython_extensions's Issues

duplicated entries in toc not functioning properly

When I have a toc like the following:

  1. HEAD_A
    1. a
    2. b
  2. HEAD_B
    1. a
    2. c
      If I press 'a' under HEAD_B, it can only jumps to the place where the 'a' under HEAD_A points to. Of course one could distinguish the two 'a' by giving them different names, but this makes the string longer and not clear.

making margin width configurable

Hi, would it be possible to make margin configurable? the hardcoded 20px on both sides is a lot of wasted work-space.

Currently I had to change it manually:

--- toc2/toc2.js.orig   2018-07-06 15:00:27.139881888 -0700
+++ toc2/toc2.js        2018-07-06 15:00:36.359743263 -0700
@@ -224,7 +224,7 @@
     }

     function setNotebookWidth(cfg, st) {
-        var margin = 20;
+        var margin = 5;
         var nb_inner = $('#notebook-container');
         var nb_wrap_w = $('#notebook').width();
         var sidebar = $('#toc-wrapper');

Thank you.

Load timeout for modules

Hi,

First, I really like your extension, it's really useful when editing large IPython notebooks to navigate efficiently.

The problem is that with large Ipython notebooks, I'm getting a timeout error on one of my machines (the slowest of the two, and only on the biggest notebook I have).

Opening up the firefox dev console, I can see the following error:

"Failed to load extension(s):" Array [ "nbextensions/gist", "nbextensions/toc" ] Error: Load timeout for modules: nbextensions/gist,nbextensions/toc
http://requirejs.org/docs/errors.html#timeout
Stack trace:
makeError@http://localhost:8888/static/components/requirejs/require.js?v=640929dac3c23a448d2eebc37bc32062:166:17
checkLoaded@http://localhost:8888/static/components/requirejs/require.js?v=640929dac3c23a448d2eebc37bc32062:692:23
checkLoaded/checkLoadedTimeoutId<@http://localhost:8888/static/components/requirejs/require.js?v=640929dac3c23a448d2eebc37bc32062:713:25

It is indeed a proper timeout error as far as I can tell since it only happens on large notebooks, and if I keep refreshing the page eventually it will succeed (I'm probably very close to the time limitation).

requireJS has a 7 second default (documentation here). Apparently one can configure waitSeconds to any value (including 0 for unlimited). That's what I'd like to do, but I'm completely illiterate in javascript/jquery.

From what I understand from this page I'd have to create an app.js with the requirejs.config stuff and the call to your toc.js and then setup my custom.js to load app.js instead of toc.js?

Any idea if there's a better or easier way?

Thank you, and keep up the good work

Install path for nbtoc is wrong

Hi there::

In [1]: %install_ext https://rawgithub.com/minrk/ipython_extensions/master/extensions/nbtoc.py
Installed nbtoc.py. To use it, type:
  %load_ext nbtoc

In [2]: %load_ext nbtoc
Downloading https://raw.github.com/minrk/ipython_extensions/master/nbtoc.js to /home/tom/.config/ipython/extensions/nbtoc.js
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-2-ddede4bd44dd> in <module>()

 [... snip...]

HTTPError: HTTP Error 404: Not Found

I'm assuming this is because the js-file was moved into the 'nbextensions' directory in the repo, but the download-path in nbtoc.py hasn't been updated yet to reflect this.

floating TOC is too small

The floating TOC only has the first 5 sections of my notebook, and the rest of the toc shows up on the left, but these links don't work. Also, the TOC on the left duplicates each time I refresh the TOC.

TOC not shown after a notebook reload

Opening a notebook will not show the TOC, even if that was added (and executed) during the last session. The box is there, but only the text "Content [hide]" is shown, but not the links to the headlines. It seems that the display_html content is preserved over reloads, but not the display_javascript one.

(chrome browser)

It would also be nice if the nbtoc could be added as javascript extension, so that it can be used in every notebook without executing anything.

Error on install

My Gist button disappeared literally overnight along with the Edit Presentation/ Show Presentation buttons. On trying to reactivate the extension I had the error

ValueError: Expecting ',' delimiter: line 8 column 3 (char 115)

but deleting ~/anaconda2/etc/jupyter/jupyter_notebook_config.json had no effect - same thing!

Jupyter version 4.3.0

feature request: let the toc itself support folding

In modern word editors or pdf views, they all support folding of toc. It is really needed if the notebook is very large and the toc itself gets very long and contains many levels. So I'm looking forward to this feature to be added, thanks.

Headings for TOC no more supported

We cannot mark any cell as "heading" type. Looks like it is not supported anymore. It pops up the following message. "Jupyter no longer uses special heading cells. Instead, write your headings in Markdown cells using # characters"

Any other alternative?

nbtoc does not work with markdown headlines

Nice new ToC plugin, thanks!

Unfortunately it doesn't recognize Markdown generated headlines.

Here are two examples (first H1 cell, second a markdown cell with a single entry "#MD-h1"), the first is turned into a ToC entry, the second only shows up as a number without the text.

<h1><a class="heading-anchor" href="#H1-cell" id="H1-cell">H1-cell</a></h1>
<h1>MD-h1</h1>

Not sure how to fix that, my jquery isn't good enough for this :-/

contribute the nbextensions (at least toc) to ipython-contrib/IPython-notebook-extensions

https://github.com/ipython-contrib/IPython-notebook-extensions seems to become the "go-to" repo for jupyter notebook extensions and the new webinterface to enable/disable extensions is great. Would it be possible to move the nbextension to that repo?

I'm not sure where the python extensions should go, %install_ext still works but it spits out a big deprecation warning:

C:\portabel\miniconda\envs\dev_34\lib\site-packages\IPython\core\magics\extension.py:47: UserWarning: %install_ext` is deprecated, please distribute your extension(s)as a python packages.
  "as a python packages.", UserWarning)

cc: @juhasch

gist extension will not work on chrome due to security feature.

This is more a warning than an issue - the handy-looking "gist" extension does not currently work on chrome due to a security feature.

The following error appears in the javascript console:
XMLHttpRequest cannot load https://api.github.com/gists. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8888' is therefore not allowed access.

The pop-up error message does not say anything. This appears to come from a chrome security feature discussed here:
https://code.google.com/p/chromium/issues/detail?id=40787

and here:
https://code.google.com/p/chromium/issues/detail?id=47416

How can I contribute to the table of content extension?

I thought about build a toc extension, but then found here is one. Personally, I want to add a few tweaks to it, but don't know about the workflow working with building extensions for Ipython Notebook

Is there any instruction of it?
Addtionally, I find writing html inside js is intimidating, is it possible to extract it out?

Two install instructions for ToC

Git's readme says "download toc.js and toc.css and add this code to custom.js". However, toc.js gives a different piece of code to add to custom.js.

The first one worked fine for a small notebook that I have, but not for a large one for which I had to increase the RequireJS timeout. Removing the stuff I added to custom.js (the install way from README.md) and adding what the toc.js file suggested (after the line that is increasing the timeout) fixed my problem, so maybe README.md should be updated with this.

It probably doesn't matter much, but I'm running IPython Notebook Server 3.2.0-8b0eef4 with Python 3.3.2.

gist notebook extension doesn't add buttons

I installed gist extension from:

https://raw.githubusercontent.com/minrk/ipython_extensions/master/extensions/gist.py

and then loaded it using %load_ext.

Starting a notebook results in the following error in js console on Chrome and Safari:

gist extension loaded               custom.js:54
Uncaught TypeError: Cannot read property 'add_buttons_group' of undefined       gistcomm.js:79
GistButton.setup_gist_button        gistcomm.js:79
load_extension                      gistcomm.js:98
(anonymous function)                custom.js:55
context.execCb                      require.js:1650
Module.check                        require.js:866
(anonymous function)                require.js:1113
(anonymous function)                require.js:132
(anonymous function)                require.js:1156
each                                require.js:57
Module.emit                         require.js:1155
Module.check                        require.js:917
Module.enable                       require.js:1143
Module.init                         require.js:774
callGetModule                       require.js:1170
context.completeLoad                require.js:1544
context.onScriptLoad                require.js:1671

and no gist button is added, while it should.

Unable to use TOC

I tried to use the automatical TOC generator, toc.js, but having got an error.
Although I followed the suggestion on "https://github.com/minrk/ipython_extensions#table-of-contents", it sill does't work.

I put 'extensions' and 'nbextensions' directories inside my '/.config/ipython' as the command 'ipython locate' told. And my custom.js inside '/.config/ipython/default_profile/static/custom' is:

IPython.load_extensions('toc');

However, an error on loading custom.js in Chrome webbrowser still occur.
That is:

'Uncaught TypeError: undefined is not a function'

I don't know how to solve this. Please help.

README instructions do not work

Copy & paste of the install instruction from the readme file:

curl https://rawgithub.com/minrk/ipython_extensions/master/nbextensions/gist.js > $(ipython locate)/nbextensions/gist.js

Resulted in the following error and an empty gist.js being stored in the nbextensions directory

0curl: (77) error setting certificate verify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none

using wget instead, worked out fine.

By the way, I also found another gist_it.js under https://github.com/ipython-contrib/IPython-notebook-extensions Are there plans to merge those two?

Unload retina extension

Thanks for the retina extension, it really makes it easy to get high quality graphics on a retina display. Could you provide an unload function as well? I keep switching between working from emacs or from the browser on some notebooks and it takes significantly longer on my machine to render the high resolution pictures in the Emacs IPython Notebook then the standard one.

Keep up the good job!

TypeError: IPython is undefined toc.js:136:8

Hi,

I tried to install ToC extension but I am getting the error TypeError: IPython is undefined
toc.js:136:8.
IPython verson: 2.3.0

my custom.js file:

$([IPython.events]).on("app_initialized.NotebookApp", function () {
IPython.load_extensions("toc");
});

ENH: Undo delete cell

To often I hit crtl-m-d when I really wanted crtl-m-b. It's beyond my own IPython understand, but it would be nice to have an undo-delete.

token not deleted when authorization fails

When I press the "Share Notebook" button it fails with: Uploading gist failed: Unauthorized. I previously entered a token.

Looking at the code, then token should be deleted when authorization fails:

    if (true || jqXHR.status == 403) {
        // authentication failed,
        // delete the token so that we prompt again next time
           delete localStorage[token_name];
    }

What's going wrong?

Jupyter notebook 4 hangs with TOC extension

As in the title, in one machine (Win 7) with TOC extension installed has been migrated to jupyter 4.x. The extension caused the notebook to hang when opening a notebook (a new tab is opened, I see the Jupyter header but the notebook content is not loaded).

Upon commenting the relevant line in custom.js the issue was solved.

On a second machine (OSX) with jupyter notebook 4.0.4 already installed, I downloaded toc.js/css with curl, then I tried installing the TOC extension by adding:

$([IPython.events]).on("app_initialized.NotebookApp", function () {
    IPython.load_extensions("toc");
});

to .jupyter/custom/custom.js (I had to create the custom folder and the custom.js file).

Am I doing something wrong?

EDIT: fix typos

nbtoc - numbering issue

Great plugin ! I found the 'content' topic yesterday and this morning the plugin is operational !

I have an issue on the numbering. A small picture is better than hard explanations :

ipynb_toc_issue

In 'reascending order', levels are not right managed. It should be something in the js function, but at first glance the problem is not evident to me.

Table of content issue: 404 warning

Hi, I have followed your indications and tried the promising toc extension but it does not seem to work for me. The following messages appear:

WARNING:root:404 GET /static/nbextensions/toc.js (127.0.0.1)

and no toc button appear in my notebook. Any idea what I did wrong?

my ipython version: 1.7.1

What I did:
create the directory: /home/perrette/.ipython/profile_default/static/custom
and create a custom.js containing:

require(["nbextensions/toc"], function (toc) {
    console.log('Table of Contents extension loaded');
    toc.load_extension();
});

create nbextensions under ~/.ipython, and download toc.css and toc.js in there.
create symbolic link toward my directory (NOTE: the target and origin are inverted in the readme)

Full log below:

2014-02-02 18:27:20.417 [NotebookApp] Using existing profile dir: u'/home/perrette/.ipython/profile_default'
2014-02-02 18:27:20.423 [NotebookApp] Using MathJax from CDN: http://cdn.mathjax.org/mathjax/latest/MathJax.js
2014-02-02 18:27:20.442 [NotebookApp] Serving notebooks from local directory: /media/PIK/Projects/dimarray
2014-02-02 18:27:20.442 [NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888/
2014-02-02 18:27:20.442 [NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Created new window in existing browser session.
WARNING:root:404 GET /static/nbextensions/toc.js (127.0.0.1) 0.39ms
WARNING:root:404 GET /static/nbextensions/toc.js (127.0.0.1) 0.40ms
2014-02-02 18:28:00.249 [NotebookApp] Connecting to: tcp://127.0.0.1:41923
2014-02-02 18:28:00.251 [NotebookApp] Kernel started: f37ce302-7c21-48b6-8c0d-4bdce231c724
2014-02-02 18:28:00.638 [NotebookApp] Connecting to: tcp://127.0.0.1:38255
2014-02-02 18:28:00.801 [NotebookApp] Connecting to: tcp://127.0.0.1:39238
2014-02-02 18:28:00.853 [NotebookApp] Connecting to: tcp://127.0.0.1:48957

Thanks for the good work !

toc fails to generate entries for headlines with tex

When you use the wonderful nbtoc extension
but use latex at the same time, you don't have anything in the TOC to click one.

One simple workaround would be to just show the raw markdown content, all the time

issues with TOC installation

Hi,

Just tried installing TOC extension on a mac book. didn't succeed. which custom.js file should I edit and where the TOC button should appear in the notebook?

I've added the line to the file in:
~/anaconda/lib/python2.7/site-packages/IPython/html/static/custom/custom.js

yet I see no TOC button.

Thanks!

string including "] will cause In[*] problem

I accidentally found "In[*]" problem.

In markdown cell, strings including "] will cause a problem.
Once that markdown cell executed, cells below will display "In[*]" instead "In[5]".
Cells above are not affected.

When I disabled this extension(Table of Contents (2)), no problem occurred.
Please check the picture.

screenclip 2

TOC links don't jump to headers?

Hi, I am really loving the idea of this ipython notebook extension but am having some trouble getting it to work. I installed the extension and it seems to work on first glance, but when I click on the links in the TOC, it doesn't actually jump to any of the headers, even through the url is changing in the url bar. I tried this in both safari and chrome and the same behavior occurs. Everything should be updated so I'm not sure where the issue is coming from...

Target released version?

How much work would it be to have a branch that targets the current release of IPython? Otherwise, do you know the last commit that works with 2.3.1 for the table of contents stuff? The parent of the 3.x fixup for toc.js doesn't seem to work quite right.

nbtoc update bug?

I am using the most recent ipython from git as of now. If I do '%nbtoc' in a notebook cell, it does not regenerate toc, but generate one more toc that overlaps existing toc. If I close the notebook and reload, toc shows up correctly.

This seems to be a bug. Or, is there a way to update toc differently?

ssp_temp_capture

TOC doesnt load?

Hello,

I am on windows running the conda suite of packages and have ipython 2.3.1. I ahve followed the steps for the table of contents, placing

$([IPython.events]).on("app_initialized.NotebookApp", function () {
    IPython.load_extensions("toc");
});

in my C:\Users\diego\.ipython\profile_default\static\custom\custom.js file. I restart ipython and do not see any indication that the TOC extension is working.

install renumber-button via URL?

Is it possible to install the renumber-button extension via the URL like the ToC and gist examples in the README? When I try I get:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   178  100   178    0     0    563      0 --:--:-- --:--:-- --:--:--   568
100  1114    0  1114    0     0   2392      0 --:--:-- --:--:-- --:--:--  2392
Please specify one nbextension/package at a time

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.