<commit_before>from lxml import html

def html_minify(html_code):
    html_code = unicode(html_code)
    dom = html.fromstring(html_code)
    html_code = html.tostring(dom, method='xml', encoding=unicode)

    minified_lines = []
    for line in html_code.split('\n'):
        minified_line = line.strip()
        if minified_line:
            minified_lines.append(minified_line)

    return u"".join(minified_lines)
<commit_msg>Very ugly test for excluding <script> from minifying<commit_after>from lxml import html

def html_minify(html_code):
    html_code = unicode(html_code)
    dom = html.fromstring(html_code)
    html_code = html.tostring(dom, method='xml', encoding=unicode)

    script = False
    minified_lines = []
    for line in html_code.split('\n'):
        if '</script>' in line:
            script = False

        if script:
            minified_line = "%s\n" % line.rstrip()
        else:
            minified_line = line.strip()

        minified_lines.append(minified_line)

        if '<script' in line:
            script = True
            first = True
            minified_lines.append('\n')

    return u"".join(minified_lines)

{'fraction_non_alphanumeric': 0.10698878343399482, 'fraction_numerical': 0.0, 'mean_word_length': 2.6363636363636362, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6154358', 'n_tokens_mistral': 371, 'n_tokens_neox': 361, 'n_words': 80}