Re: Pull dictionary of docinfo fields from a document?

Guenter Milde via Docutils-users <[email protected]>
Newsgroups gmane.text.docutils.user
Message-ID <[email protected]>
On 2017-07-30, Tony Narlock wrote:

> My intention is to use DocInfo as a way to scape meta information off RST
> files to build an index of them.

> There is a DocInfo transformer at docinfo.transforms.frontmatter.DocInfo.

> Two things:

> 1. I don’t want DocInfo fields to show on HTMLWriter

Either hide them with CSS or strip with the setting:

 --strip-elements-with-class=<class>
                        Remove all elements with classes="<class>" from the
                        document tree. Warning: potentially dangerous; use
                        with caution. (Multiple-use option.)


> 2. I want to pull a python dictionary of key->value fields from DocInfo.

...

> My understanding is DocInfo handles that fields in biblio_nodes, but also
> can handle arbitrary field names. (
> http://docutils.sourceforge.net/docs/ref/doctree.html#docinfo). Is that
> true?

Yes.

Check with, e.g. rst2pseudoxml, this gives a nice representation of the
doctree. Then you can, e.g. create a function to convert the docinfo
sub-tree into the dict. The transforms will give some hints on how to wald
around the doctree and collect information.

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.