Re: publish_parts and table of contents?

Guenter Milde via Docutils-users <[email protected]>
Newsgroups gmane.text.docutils.user
Message-ID <[email protected]>
On 2017-07-20, Tony Narlock wrote:
> On July 19, 2017 at 5:27:15 PM, Guenter Milde via Docutils-users (
> [email protected]) wrote:
> On 2017-07-19, Tony Narlock wrote:

> ...

>> The transform generates the TOC by travelling the document tree after
>> parsing is complete.

...

>> https://gist.github.com/tony/c4fc5661fcd4b7de71c65dd8a52c9ea4

> Which contains the description:

>> 1. Currently, table of contents is only outputted through directive.
> ...
>> 3. I want it to be available in "toc" *without* using the directive in the
>> source.

> For this, you would need to run the "Contents" transform also if the
> document does not contain the "contents" directive.


>> 2. I do not to position table of contents in the RST. (therefore, I
>> specifically do not want it in html_body)


I suppose rather than messing with "parts", you can use the publish_*
functions in a wrapper script:

Don't use ``.. contents..`` in the source.

1. Parse the rst source with publish_doctree()
   
   Returns a doctree object.
   

2. Export doctree to HTML with publish_from_doctree()

3. Run the toc-generating transform on the doctree.
   Returns a "toc doctree".
   
4. Export the "toc doctree" with publish_from_doctree().   

This is just an idea, not tested and detailled.   

> It would be indispensable to get a code example or demonstration.

This is left as an exercise to the reader.


Günter



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.