Re: publish_parts and table of contents?

Tony Narlock <[email protected]>
Newsgroups gmane.text.docutils.user
Message-ID <CAC8GGzOuyPy37EeiKS8iU=tM_BZ5XfG5g=hhzncAp9cDwAFh0Q@mail.gmail.com>
Here’s where it’s at now (after looking at footer and PEP code):
https://gist.github.com/tony/9c0d5eaa081b5ff611b7ca9e86a83046

Output:

<div class="toc">
<hr class="toc" />
<div class="contents topic" id="contents">
<p class="topic-title first">Contents</p>
</div>

</div>

So stuff is showing in TOC. But the pending contents information doesn’t
seem to be rendering.

On July 21, 2017 at 11:07:44 AM, Tony Narlock ([email protected]) wrote:

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.