Re: publish_parts and table of contents?

Tony Narlock <[email protected]>
Newsgroups gmane.text.docutils.user
Message-ID <CAC8GGzPrbJ1=_vJ9ypXxapq1=14n8DN8FJC5W8cDE_jt6tLhYg@mail.gmail.com>
So here is where I am:
https://gist.github.com/tony/1a03b7668c9e33672f4465dd63c6076b

On July 20, 2017 at 11:54:07 AM, Guenter Milde via Docutils-users (
[email protected]) wrote:

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".

Where would it be? Am I applying the transform correctly in the paste?



4. Export the "toc doctree" with publish_from_doctree().

Assuming I’m running the transform correctly, I see no difference in the
output.



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.

This has been educational and is helping me understand internals better. I
prefer vanilla docutils whenever possible.

Any more ideas?




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.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
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.