|
From: David G. <go...@us...> - 2002-05-22 04:25:58
|
Engelbert Gruber wrote: > visit_Text is called on leaves i guess ? Yes, ``visit_Text`` is called whenever a ``nodes.Text`` instance is encountered. ``nodes.Text`` objects are terminal nodes (leaves) containing text only; no child nodes or attributes. > i recognized a new function supports in the writer: > means the parser could ask the writer if it supports a certain > construct and if not might use some other ? No, writers should support all elements defined in docutils.nodes. There's no communication between parser and writer at parse time. The fully parsed document instance may contain "pending" elements, which are a form of delayed communication, and that's what the "supports" method can be used for. ``docutils.Component.supports()`` (defined in docutils/__init__.py) is used by transforms to ask the component (reader or writer) controlling the transform if that component supports a certain input context or output format. Specifically, it's used by the "meta" directive, which uses the ``docutils.transforms.components.Filter`` transform; only writers supporting HTML will include the meta tag, others will discard it. (See the docstring of ``docutils.transforms.components.Filter`` for a detailed explanation.) I've updated the docstring. > the NodeVisitor has all visit_ departure_ procedures > defined. this way a writer might not know that he missed something > which makes it hard to support everything if you donot know. This aspect is useful for sparse traversals, such as those done by transforms. It's not so useful for writers, though, as you say. I've removed the definitions of ``visit_...`` and ``depart_...`` methods from NodeVisitor, and added a new subclass, SparseNodeVisitor. You'll want your PDFTranslator to continue subclassing NodeVisitor. -- David Goodger <go...@us...> Open-source projects: - Python Docutils: http://docutils.sourceforge.net/ (includes reStructuredText: http://docutils.sf.net/rst.html) - The Go Tools Project: http://gotools.sourceforge.net/ |