minrk / ipython_extensions Goto Github PK
View Code? Open in Web Editor NEWMy IPython extensions
License: Other
My IPython extensions
License: Other
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
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 :-/
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
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...
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.
I'm wondering if these extensions (or at least a subset of them) are expected to work with arbitrary custom kernels. Obviously magics will not be guaranteed to work with any kernel, but ones like gist, ToC, etc. should, no?
Thanks!
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?
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.
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.
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");
});
I would like to clone the repository into a subdirectory of my extensions directory but right now this fails when I try to load a extension because the new subdir misses a init.py file.
Adding a empty init.py makes it possible to %load_ext ipython_extensions.nbtoc
.
When trying to export a notebook with a table of contents the floating window appears, but with no content.
As an example of this, see this nbviewer page that demonstrates this extension.
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?
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 :
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.
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.
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
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.
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
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!
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?
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
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!
to write the metadata
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.
Great extension. But there seems to be a problem in grabbing the JSON code that it posts to Gist, such that nbviewer throws a 500 error when trying to open it. When I copy the raw JSON code myself into the Gist web interface it works fine.
Here's an example of a notebook posted using the button:
https://gist.github.com/bf9692b833727299c1f9
And here's the same notebook posted manually:
https://gist.github.com/d1a2d7075c5e13f9e840
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.
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.
In first line: should be "jupyter" not "juptyer".
Thanks for this compilation. toc
works nicely.
The formating gives always shows one hour too many:
print time.strftime(u"%H:%M:%S", time.localtime(1))
01:00:01
print time.strftime(u"%H:%M:%S", time.localtime(60*60*3+61))
04:01:01
I think the easiest fix would be to copy the _format_time
function from https://github.com/ipython/ipython/blob/master/IPython/core/magics/execution.py
Hello. Is it possible to add the possibility to show/hide table of contents with a keyboard shortcut? Or it can be done easily somehow by the user?
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.
Edit: just found out that there is a new version which works as a nbextension -> maybe the nbtoc magic should be removed?
I believe that to work with the current IPython release, line 9 of nbinput.py (so very useful!) should be
from IPython.display import display, Javascript
Thanks!
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?
It appears that ipython-3.0 don't support heading cells, as a result the toc extention is not able to generate toc any longer.
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.
Headings are not shown when using %nbtoc
.
Section numbers are off after using subsubsections.
When I have a toc like the following:
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
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
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.
When I save the notebook or refresh the TOC, the TOC duplicates it self.
When entering a heading and executing the cell, the ToC is not updated.
Only after re-enabling the ToC via the button in the toolbar.
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?
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.
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 !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.