'>>> t = Textile()
>>> t.block(\'h1. foobar baby\')
\'\t<h1>foobar baby</h1>\''

def block(self, text, head_offset=0):

    if (not self.lite):
        tre = '|'.join(self.btag)
    else:
        tre = '|'.join(self.btag_lite)
    text = text.split('\n\n')
    tag = 'p'
    atts = cite = graf = ext = c1 = ''
    out = []
    anon = False
    for line in text:
        pattern = ('^(%s)(%s%s)\\.(\\.?)(?::(\\S+))?    (.*)$' % (tre, self.a, self.c))
        match = re.search(pattern, line, re.S)
        if match:
            if ext:
                out.append((out.pop() + c1))
            (tag, atts, ext, cite, graf) = match.groups()
            h_match = re.search('h([1-6])', tag)
            if h_match:
                (head_level,) = h_match.groups()
                tag = ('h%i' % max(1, min((int(head_level) + head_offset), 6)))
            (o1, o2, content, c2, c1) = self.fBlock(tag, atts, ext, cite, graf)
            if ext:
                line = ('%s%s%s%s' % (o1, o2, content, c2))
            else:
                line = ('%s%s%s%s%s' % (o1, o2, content, c2, c1))
        else:
            anon = True
            if (ext or (not re.search('^\\s', line))):
                (o1, o2, content, c2, c1) = self.fBlock(tag, atts, ext, cite, line)
                if ((tag == 'p') and (not self.hasRawText(content))):
                    line = content
                else:
                    line = ('%s%s%s' % (o2, content, c2))
            else:
                line = self.graf(line)
        line = self.doPBr(line)
        if (self.html_type == 'xhtml'):
            line = re.sub('<br>', '<br    />', line)
        if (ext and anon):
            out.append(((out.pop() + '\n') + line))
        else:
            out.append(line)
        if (not ext):
            tag = 'p'
            atts = ''
            cite = ''
            graf = ''
    if ext:
        out.append((out.pop() + c1))
    return '\n\n'.join(out)
