Re: publish_parts and table of contents?
Tony Narlock <[email protected]>
| Newsgroups | gmane.text.docutils.user |
|---|---|
| Message-ID | <CAC8GGzPuGS1gG9VRDr_EqbGifG8DVwsgS3KA3Q0NGmF7=GcRQA@mail.gmail.com> |
I’m getting there,
I’ve overrides the Writer and added a new visitor attribute for “toc”.
visitor_attributes = Writer.visitor_attributes + ('toc', )
So “toc” should be collected during assemble_parts.
From here, I want to inject the TOC the document into “toc”.
There’s transforms.parts.Content(), but I’m not sure where and how I’d put
it into play.
There is also a directive for parsers.rst.directives.parts.Contents. I’m
curious how I would go about injecting that.
So how do you think I can go about that? Could you give me a code example
to how I could get the equivalent of .. contents:: showing up in a “toc”
part of writer?
Best,
On July 18, 2017 at 1:32:12 PM, Guenter Milde via Docutils-users (
[email protected]) wrote:
On 2017-07-18, Tony Narlock wrote:
> Is there a way to get the equivalent to “.. contents::” from
publish_parts?
According to
http://docutils.sourceforge.net/docs/api/publisher.html#publish-parts-details
,
no.
> If not, is there any way to get the table of contents programmatically?
This could be done in a wrapper; or a custom writer or front-end.
Places to look include the transforms.parts.Content() and the used HTML
writer.
> If not, is there any reason / issue with it being a feature?
I don't know.
> The practical use is a developer pulling out parts the HTML output would
> like control over the table of contents output.
The simple and secure approach would be CSS styling --- unless the task is
more complicated.
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