Hi,
 
I am in the very first experimental stage of developing a writer for Braille printing. However, I am afraid of getting bogged down on some subtle issue. And as I am fairly new to docutils and only a seasoned programmer, I thought I'd better ask the friendly docutils community for help.
 
Here is my first attempt to get acquainted with the - excellent - architecture of docutils:
 
 
class Writer(docutils.writers.Writer):
    def __init__(self):
        docutils.writers.Writer.__init__(self)
        
 
    def translate(self):
        self.visitor = BrailleVisitor(self.document)
        self.document.walk(self.visitor)
        self.output = " "
   
   
class BrailleVisitor(NodeVisitor):
    def __init__(self, document):
        NodeVisitor.__init__(self, document)
 
    def visit_document(self, node):
        print node
    def visit_paragraph(self, node):
       print node
 
Passed a simple txt file with two paragraphs, the output looks as follows:
 
<document source="test.txt"><paragraph>First paragraph...</paragraph><paragraph>Second paragraph!</paragraph></document>
<paragraph>First paragraph...</paragraph>
 
The script then exits with an AttributeError as walk doesn't stop at the end of the tree. Rather, it passes None to the dispatcher which calls unknown_visit. The latter then tries to access a non-existing settings attribute.
 
The only solution I could think of is to use walkabout with a depart_document method raising an exception. But the html writer which I tried to understand, doesn't work like this. So there must be a better way. Also, I do not understand the last line of the output: after </document> the walk should terminate. Rather, it looks as if the first paragraph is revisited...
 
Any helpful comment on this is very much appreciated. I am not subscribed to this list so please put me on cc when responding.
 
Thanks in advance,
 
Leo