|
From: David G. <go...@us...> - 2002-05-30 01:31:36
|
Sorry I've taken so long to reply; been busy.
Engelbert Gruber wrote:
> who might not know anything about the writer and i want to keep
> the writer making output, maybe ugly but never loose content.
> i.e. even if i donot know what it is then things will be
> written as standard text.
As I replied last time,
``Node.walk`` & ``Node.walkabout`` call
``NodeVisitor.unknown_visit`` & ``.unknown_departure`` when
unknown node types are encountered.
You can implement the ``unknown_visit``/``unknown_departure`` methods
of your ``NodeVisitor`` subclass to do whatever you like (such as call
``node.astext()``). If you choose to do this, I'd recommend issuing a
warning (a Python warning is OK, doesn't have to be a system_message)
saying "an unknown node (name) has been encountered", otherwise it
will be difficult to track down the remaining unimplemented node
types.
This is only an interim solution though. It's OK during development,
but the writer won't be complete until *all* node types are handled in
some way. At that point, the unknown_visit/unknown_departure methods
should be removed, so that later bugs *will* be noticed.
--
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/
|