On Sun, 05 Jan 2014 22:01:16 -0500
Offray Vladimir Luna Cárdenas <[email protected]> wrote:
> but curiously I don't know how to say: do nothing if the node is
> children of a "@ignore" parent node. ¿How can this be done? (I imagine
> that @rst-ignore code can be used for this, but I don't know where to
> look for it).
any(i.h.startswith('@ignore') for i in p.parents())
will be True if any parent of p starts with '@ignore' (which includes
"@ignore-NO!", but if you use .startswith('@ignore ') (with the space),
you miss plain "@ignore". "@ignore-NO!" is silly, so the above is ok.
I though it could be slightly faster to do:
ignore_me = False
for i in p.parents():
if i.h.startswith('@ignore'):
ignore_me = True
break
because the break will stop it processing remaining ancestors after it
hits an @ignore, but turns out any() uses short-circuit behavior, so it
will stop at the first @ignore, and the top form is fine.
Cheers -Terry
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.