Giter VIP home page Giter VIP logo

Comments (8)

asteppke avatar asteppke commented on July 22, 2024

There is unfortunately a confusing mix of documentation out there for the different ipython versions. For many extensions upgrading works nicely but not all of them.

Until this extension is officially part of the jupyter/ipython repository the easiest way to install and run this extension is to stick to the standard installation method mentioned here with one key change:

In

 .ipython/custom/custom.js

add

IPython.load_extensions('toc');

to load the extension. That is all, no other changes required.

from ipython_extensions.

tritemio avatar tritemio commented on July 22, 2024

@asteppke, adding IPython.load_extensions('toc'); in .ipython/custom/custom.js does not work for me, still the notebook hangs. Also, AFAIA the notebook will not look into .ipython folder anymore for custom.js, isn't it?

from ipython_extensions.

tritemio avatar tritemio commented on July 22, 2024

If I create .jupyter/custom/custom.js with the only content:

IPython.load_extensions('toc');

then notebook loads (no hang) but no TOC button is shown.

from ipython_extensions.

asteppke avatar asteppke commented on July 22, 2024

I looked into this again, so what I wrote worked here for the transition to ipython 3.x. This is not working for jupyter as you experienced. Until the toc extension is part of the official repository some hacking is still required. The javascript api has changed again so this is the configuration that worked here after upgrading from 3.x to jupyter:

The toc.js and toc.css should be located in the appropriate directory, e.g. on Windows for a per user installation in %AppData%\Roaming\jupyter\nbextensions.

This extension then needs to be loaded using a javascript snippet in your custom.js:

require(['base/js/utils'],
function(utils) {
    utils.load_extensions('toc');
});

To test whether this file is executed at all you can use a simple alert function additionally:

alert("hello world from custom.js")

Here the custom.js is located in .jupyter\custom\.

And finally a bit closer to the offical installation method is avoiding any custom.js hacks. Instead the extension is installed via the extension manager, then in .jupyter\nbconfig\notebook.json the extension is loaded via

{
   "load_extensions": {
   "toc": true
  }
}

from ipython_extensions.

syrte avatar syrte commented on July 22, 2024

I've installed toc nbextension successfully with Jupyter notebook 4.
I post my solution here, may it help.

## download 
mkdir toc
cd toc
wget https://raw.githubusercontent.com/minrk/ipython_extensions/master/nbextensions/toc.js
wget https://raw.githubusercontent.com/minrk/ipython_extensions/master/nbextensions/toc.css

## install and enable
cd ..
jupyter-nbextension install --user toc
jupyter-nbextension enable toc/toc

install will copy toc to ~/.local/share/jupyter/nbextensions/
enable will modify ~/.jupyter/nbconfig/notebook.json as asteppke said.
You can check these two place.

Note: we use enable toc/toc here is because toc.js is in ~/.local/share/jupyter/nbextensions/toc/
if you put toc.js and toc.css directly in ~/.local/share/jupyter/nbextensions/ then you should use enable toc here.

from ipython_extensions.

tritemio avatar tritemio commented on July 22, 2024

@styra thanks! It worked flawlessly on OS X.

You should put this info in a more visible place :). Maybe you could send @minrk a PR to update the README?

Closing the issue as the problem is solved for me.

from ipython_extensions.

jankatins avatar jankatins commented on July 22, 2024

Note that the TOC extension was recently also added to the ipython-notebook-extension repository and there you can simple activate it via the <nbserver:port>/nbextension URL.

from ipython_extensions.

syrte avatar syrte commented on July 22, 2024

@JanSchulz Thank you!
It's very impressive. Why I didn't see this earlier ...
And a typo: the URL should be <nbserver:port>/nbextensions

from ipython_extensions.

Related Issues (20)

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.