From: David G. <go...@py...> - 2017-10-17 19:50:28
|
On Thu, Oct 12, 2017 at 2:54 PM, Tony N <to...@gi...> wrote: > Since I am already able to read the title/subtitle from the doctree, now I > want to be able to remove the title and subtitle from a doctree: > > What would be the canonical way of doing that? Docutils doctree elements wrap the sequence interface (pass-through to Element.children). So use the same operations you would on a list. > - Removing the nodes.title and nodes.subtitle from the doctree (how can that > be done? Is there any examples to how that works?) Assume doctree[0] is the title element (use, e.g. ``index = Element.first_child_matching_class(nodes.title)``). ``del doctree[0]`` deletes the title. > - Removing all nodes *after* nodes.title and nodes.subtitle (any examples > for something like that?) Assume doctree[1] is the subtitle element. ``del doctree[2:]`` does what you want. DG |