On 2013-12-29, Michael Lustfield wrote:
> This function now sticks things on the page, but... I can't figure outFrom the explanations further down, I suppose you want to add a heading
> how to register a heading. The heading I want to register will always
> be the same level.
element to the document tree. In the docutils sources, there are examples
of both: directives that add more than one node to the document tree and
a directive that adds a heading node. The right combination of these
should do what you expect.
> I also need to figure out how to print that to the screen.Do you mean the HTML/PDF/ODF or whatever output? Once you have the
correct element node added to the document tree (at the right place),
conversion to the output format should be done by the writer without
further effort. This is the nice thing about the separation of parsing,
transforming and writing steps.
For me, a help in creating such directives was to re-create the intended
> A very basic example of what I'm trying to do is...
> .. mydirective:: fuzzy
> was a
> I would like to do two things with this directive. I first want the
> argument to generate a title and the first line to generate a table,
> followed by the remaining stuff.
> If I weren't making this directive, it would be something more like this...
> *Title 1* A
> *Title 2* b
> *Title 3* c
> *Title 4* d
> was a
> This is a grossly simplified version, but basically explains exactly what I
> need. I need to first, register that heading, then I need to generate a
> I really hope this makes sense. I'm struggling to explain it and really hope
> that someone can help me figure this out.
behaviour in rst (as you do above) and then have a look at the rst2pseudoxml
or rst2xml output to see what the relevant part of the document tree looks
like. Then I go to docutils/docutils/parsers/rst/directives and look for
examples to copy and paste and adapt.