6.14.4. Plain text weaver

This nasty weaver tries to output plain text that can be published on the Internet. It can underline headings, and flow text with left justification (and should be able to format tables), but the results are rather crude. Right justification is possible, but not implemented because, in my experience, the results are woeful.
Start python section to interscript/weavers/text.py[1 /11 ] Next Last
     1: #line 11 "text_weaver.ipk"
     2: from interscript.weavers.base import weaver_base
     3: import string
     4: 
     5: from interscript.drivers.sinks.bufdisk import named_file_sink
     6: def mk_text(pass_frame,basename, directory, prefix, eol, title, language):
     7:   if language: filename = directory + language + '_' + basename + '.txt'
     8:   else: filename = directory + basename + '.txt'
     9:   w = named_file_sink(pass_frame,filename, prefix)
    10:   if not title: title = basename
    11:   return plain_text_weaver(pass_frame,w, title=title,language=language)
    12: 
    13: class table_rule_object: pass
    14: 
    15: class plain_text_weaver(weaver_base):
    16:   def __init__(self, pass_frame,writer,language='',**kwds):
    17:     weaver_base.__init__(self, pass_frame, language)
    18:     if 'weavers' in self.process.trace:
    19:       print 'initialising plain text weaver, writer',writer.get_sink_name()
    20:     self.protocol = ('text/plain',1)
    21:     self.persistent_frame['protocol']=self.protocol
    22:     self.width = 55
    23:     self.c = 0
    24:     self.buffer = ''
    25:     self.strong = 0
    26:     self.string = string
    27:     self.code = 0
    28:     self.sink = writer
    29:     self.name = 'plain text weaver v1 for '+self.sink.name
    30:     self.persistent_frame['name']=self.name
    31:     self.tags = ['text']
    32:     self.margin = 0
    33:     self.numbered_list_stack = []
    34:     self.sop = 1
    35:     self.hcount = []
    36:     self.toc = []
    37: 
    38:   def _write(self,line):
    39:     if self.enabled:
    40:       self.sink.write(line)
    41:       self.c = self.c + len(line)
    42:     if line:
    43:       self.sop = 0
    44: 
    45:   def _writeline(self,line=''):
    46:     if self.enabled:
    47:       self._write(line+'\n')
    48:       self.c = 0
    49: 
    50:   def _goto(self,column):
    51:     if self.enabled:
    52:       if column < 0: column = self.width + column
    53:       if column < self.c: self._writeline()
    54:       if column > self.c: self._write(' '*(column-self.c))
    55: 
End python section to interscript/weavers/text.py[1]


6.14.4.1. reference processor
6.14.4.2. Table of Contents
6.14.4.3. Code File List
6.14.4.4. Code File Status
6.14.4.5. Input File List
6.14.4.6. Include List
6.14.4.7. Tables
6.14.4.8. Code Output
6.14.4.9. Citations
6.14.4.10. Citations