'Append some text to the current line.
Mimic the HTML behaviour, where all whitespace evaluates to
a single space'

def appendtxt(self, txt):

    if (not txt):
        return
    bs = es = False
    if txt[0].isspace():
        bs = True
    if txt[(len(txt) - 1)].isspace():
        es = True
    if (bs and (not self.endspace)):
        self.curline += '    '
    self.curline += txt.strip().replace('\n', '    ').replace(' DCTB ', '    ')
    if es:
        self.curline += '    '
    self.endspace = es
