Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOC #16

Open
jsoo opened this issue Jan 21, 2011 · 6 comments
Open

TOC #16

jsoo opened this issue Jan 21, 2011 · 6 comments

Comments

@jsoo
Copy link
Contributor

jsoo commented Jan 21, 2011

The addition of notelist. suggests doing something similar for a table of contents based on header IDs. Rather than trying to make a proper nested list out of it, an expedient hack would be to give each item in the TOC a class based on the header level:

<li class="h1"><a href="#foo">Foo</a></li>
<li class="h2"><a href="#bar">Bar</a></li>
@netcarver
Copy link
Contributor

Should be possible to do fairly easily.

Might this be extend to lists of other types too? Lists of tables perhaps (using table captions in place of Foo and Bar from your example above. Or maybe HTML5 sections or figures?

@eliph
Copy link

eliph commented Jan 23, 2011

I would support this idea. To illustrate how useful this feature is, here is a simple example of the TOC syntax in reStructuredText that shows how it works there:

.. contents::

Markup languages
===================

Textile
----------
Very advanced shorthand syntax for HTML

Markdown
-------------
Simple, but less powerful then Textile

reStructuredText
------------------
Mainly used for Python software documentation

And instead of

.. contents::

you may also write

.. contents::  Lightweight markup languages

to replace the default title "Contents". This can be tried in a reST sandbox, and there are other options also.

So what about using:

toc. 

to generate a TOC in Textile, for example? Alternatively toc1. , toc2. , and so on could be used for different depths.

@jsoo
Copy link
Contributor Author

jsoo commented Jan 23, 2011

Excellent possibilities here.

So as a Textplug, you would need to be able to parse the whole document. I guess that won't work with the current block-level callback?

@netcarver
Copy link
Contributor

Nope. Currently they only get a callback as the blocks are parsed, in order. This would require a two pass approach, as taken by notelists. First pass collates the data, second pass sorts it and inserts it. Doesn't mean it's impossible -- just not with the current block-level callbacks.

@wion
Copy link

wion commented Nov 25, 2018

Don’t know what the state of callbacks is these days but a more dynamic Handling of ToCs would be sweet, so it wasn’t so tedious to edit a static one when sections change.

@wion
Copy link

wion commented Dec 10, 2018

Just remembered there's the soo_toc plugin for Txp, and it works perfectly with only minor extra fuss to ensure id selectors are in headers. I'm happy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants