[IPython-User] named anchors, predictable URLs for a table-of-contents %toc magic

Catherine Devlin catherine.devlin@gmail....
Fri Mar 22 19:18:52 CDT 2013


After PyCon, I'm incredibly excited about everything I can do with the
Notebook and planning to make a LOT of rather large notebooks - so many
that it would be really nice to include a table of contents in each
notebook, with internal links to sections in the same notebook, plus
ideally to other notebooks from the same directory.  I'm thinking about how
to do that; pardon my shaky understanding of HTML and JS, I'm no web
developer.

Right now, headings in the markdown cells generate simple HTML headings
like:

<h2>Subtraction</h2>

If they wrapped each one in a named anchor, like

<a name="Subtraction"><h2>Subtraction</h2></a>

then I think we could make a %toc magic that would send back an object with
a text list of H1s and H2s and a _repr_html_ that would generate

<ol>
  <li><a href="#Subtraction">Subtraction</a></li>
  ... (etc)
</ol>

Does that sound like a workable approach?  Would hacking
frontend/html/notebook/static/pagedown/Markdown.Converter.js be the right
place to wrap the headings?

I guess a second question would be - to make links to other notebooks in
the directory - I could search through the .ipynb files in the directory to
make links, but if I find headers in MyNiftyNotebook.ipynb and make links
like <a href="MyNiftyNotebook#AboutBacon">, they'll 404 because the pages
actually have URLs like "
http://127.0.0.1:8888/9375859a-4f33-473c-a078-8e77ce51856f".  How can I
make a link to a notebook?

This StackOverflow answer don't seem promising:
http://stackoverflow.com/questions/12590611/links-between-ipython-notebooks

If it is currently impossible, would it be bad (or impossible) to hack the
server so that it could respond to /NotebookName URLs as well as to UUIDs?
 Presumably a running server keeps track of the relationship between its
.ipynb filenames and the assigned UUIDs somewhere.

Anyway, even a TOC that can't cross boundaries between notebooks would be a
great start.

If anybody wants to grab this and run with it, feel free to seize the
glory.  I'm happy to use it as a simple user if someone else wants to write
the code.
-- 
- Catherine
http://catherinedevlin.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20130322/f3c78b73/attachment.html 


More information about the IPython-User mailing list