The following snippet does the work:
http://paste.pocoo.org/show/51691/
--
Freedom is always the freedom of dissenters.
(Rosa Luxemburg)
Ok, thanks! That helped.
Any ideas why what I wanted to do didn't worked? It looks kid of hackish
adding a dummy extra node (maybe just because I almost know nothing about
docutils internals ;). There is no way to really create a new admonition
class and replace_self([]) when you don't want to show it?
--
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Did you know the originally a Danish guy invented the burglar-alarm
unfortunately, it got stolen
> It looks kid of hackish adding a dummy extra node (maybe just because I
> almost know nothing about docutils internals ;).
If this way is good enough to be used in the "official" ifconfig extension,
it can't be totally wrong to use it in your own extensions, right? ;)
> There is no way to really create a new admonition class and
> replace_self([]) when you don't want to show it?
http://paste.pocoo.org/show/51767/
Well, the writer has to support new nodes that make it through to it.
(In your first example, the "internal" node.)
The custom nodes that the ifconfig directive inserts are removed while
processing the tree, so no new node type is there for the writer to
handle.
Georg
I think that is the way this works. They share some code, but IIRC
ultimately the doc nodes generated from::
.. note::
is different from::
.. admonition:: Note
even though the resulting HTML is equivalent. They are two different
code paths because they are two different directives.
I remember that tripping up something or other that I was working on at
one point, but I don't recall exactly any circumstances. I just
remember looking at the docutils code and going "Huh, that's interesting".
--
--Max Battcher--
http://www.worldmaker.net
> Is there any way to avoid the assert? I want to remove the node, so I
> don't really care if it's loosing attributes or not.
How about removing the "classes" attribute right before replacing the
node? ;)
http://paste.pocoo.org/show/52148/
Note, that you need to adapt your style sheet to style admonitions
with "internal" class.
Since you have already created a closure, that has access to config, you can
omit the traversal of the doctree and evaluate ``config['interal']``
directly inside the directive function, which shortens the code to a little
function:
http://paste.pocoo.org/show/52295/