'Renders the contents of this tag as a string in the given
encoding. If encoding is None, returns a Unicode string..'

def renderContents(self, encoding=DEFAULT_OUTPUT_ENCODING, prettyPrint=False, indentLevel=0):

    s = []
    for c in self:
        text = None
        if isinstance(c, NavigableString):
            text = c.__str__(encoding)
        elif isinstance(c, Tag):
            s.append(c.__str__(encoding, prettyPrint, indentLevel))
        if (text and prettyPrint):
            text = text.strip()
        if text:
            if prettyPrint:
                s.append(('    ' * (indentLevel - 1)))
            s.append(text)
            if prettyPrint:
                s.append('\n')
    return ''.join(s)
