

def beautify(self):
    beautiful = ''
    replaceWithSpace = self.remove_newlines(' ')
    raw = self.source_text
    raw = self.remove_js(raw)
    raw = self.remove_css(raw)
    raw = self.remove_comments(raw)
    raw = re.sub('(<[^! ]|(?<!/\\*|//)\\]\\]>|(?<!<!\\[endif\\])-->)', '\\n\\1', raw)
    raw = re.sub('(>|(?<!/\\*|//)<!\\[CDATA\\[|<!--(?!\\[if .+?\\]>))', '\\1\\n', raw)
    raw = re.sub('(\\{{2,}(?:::)?)\\s?(.*?)\\s?(\\}{2,})', '\\1 \\2 \\3', re.sub('\\{(?:\\s*\\{)+\\s?[\\s\\S]*?\\s?\\}(?:\\s*\\})+', self.remove_newlines(), raw))
    raw = re.sub('"[^"]*"', replaceWithSpace, raw)
    raw = re.compile('(?<=\\n)<(?!/).*?>(?=\\n)', re.S).sub(replaceWithSpace, raw)
    raw = self.singletons.sub('<\\1\\2/>', raw)
    raw = self.singletons.sub(replaceWithSpace, raw)
    raw = re.sub('(?<!\\s)\\s(?=/?>)', '', raw)
    raw = re.sub('\\n{2,}', '\\n', raw)
    for l in re.split('\n', raw):
        l = l.strip()
        if (l == ''):
            continue
        if re.match('</|]]>|(?:<!\\[endif\\])?-->', l):
            self.indent_level -= 1
        beautiful += ((self.indent_char * self.indent_level) * self.indent_size)
        if self.expand_tags:
            beautiful += re.sub('^<.*>$', self.expand_tag, l)
        else:
            beautiful += l
        beautiful += '\n'
        if self.singletons.search(l):
            pass
        elif re.match('<!--|<!\\[CDATA\\[|<[^/?! ]', l):
            self.indent_level += 1
    if ((not (self.indent_level == 0)) and self.exception_on_tag_mismatch):
        raise Exception('Mismatched tags')
    if self.reduce_empty_tags:
        beautiful = re.sub('<(\\S+)([^>]*)>\\s+</\\1>', '<\\1\\2></\\1>', beautiful)
    beautiful = self.replace_comments(beautiful)
    beautiful = self.replace_css(beautiful)
    beautiful = self.replace_js(beautiful)
    return beautiful

dataset/ETHPy150Open akalongman/sublimetext-codeformatter/codeformatter/lib/htmlbeautifier/__init__.py Beautifier.beautify/original