Possible to import multiple toc from @nebrious/indented-toc?

So this totally didn’t work as I was hoping:

Any chance I can render multiple ToC within a notebook for a dynamic composite ToC?

edit Apologies for being too terse:

I have several notebooks with Tables of Contents. Each independently works in the context of the notebook. Each can also be embedded–but only when I embed the entire notebook (I just discovered this):

… What I was trying to do was to embed the rendered ToC into another notebook, which is effectively a massive outline of may several independent chapters. Seeing now, however, that the individual rendered toc() cells are not embedding, I suspect that there will be no “easy solution” to this issue. I also see here that trying to embed both ToC are causing interference. … Alas!

That helper parses the current page to build the toc.

Technically it’s not possible to determine the tree of contents until you’ve rendered the entire notebook, with every cell in it. If this were a “proper” TOC with static links, you could then inspect and copy its HTML and paste it into your notebook. Alas, that’s not going to work in this case, because

  1. there are no anchors to point the links to, and
  2. even if there were, they wouldn’t work, because you can only link to cells (via the cell menu’s “Copy link” option).

As tedious as it might be: My recommendation would be to construct your TOC manually, and have the links point to the individual cells. If you name your TOC cell, you can then also import it into other notebooks.

1 Like

Manual it shall be!

I have effectively been following the approach you outline (though not the the extent of creating anchor links). I was hoping to automate as some of my team members are complaining about content getting outdated as they work. Thank you for clarifying why this approach failed :slight_smile:

I think some degree of automation is possible. Let me see if I can come up with a demo.

@aaronkyle Here you go: Extracting a Notebook's Table of Contents / Fabian Iwand / Observable

2 Likes

You never cease to amaze me with how you are capable of anything (as well as your boundless generosity)! Thank you!

2 Likes

@aaronkyle Thank you for the kind words! Are you OK with me using one of your notebooks as the default example? Happy to change it to something else if you’d prefer that.

It’s great! Hope that notebook gets more attention! :relaxed:

1 Like