[IPython-User] named anchors, predictable URLs for a table-of-contents %toc magic
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
Right now, headings in the markdown cells generate simple HTML headings
If they wrapped each one in a named anchor, like
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
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:
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
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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-User