<commit_before>from datetime import datetime
import re

from flask import Flask, Response, abort, stream_with_context, render_template

from wake import base


app = Flask(__name__, static_folder='../build/static')


def entity_whitespace(html):
    def entity(match):
        return '&#' + str(ord(match.group())) + ';'
    return '<pre>' + re.sub('\s', entity, html) + '</pre>'


@app.after_request
def after(response):
    if response.mimetype != 'text/html':
        return response

    # minify html
    data = response.response
    def stream_minified():
        for html in data:
            html = re.sub(
                r"<pre>(.*?)</pre>",
                lambda m: entity_whitespace(m.group(1)),
                html,
                flags=re.DOTALL,
            )
            html = re.sub(r"\s+", " ", html)
            html = re.sub(r">\s*<", "><", html)
            yield html

    response.headers.pop('Content-Length', None)
    response.response = stream_minified()

    return response


with app.open_resource('../build/static/main.css') as f:<commit_msg>Remove whitespace around tag brackets.<commit_after>from datetime import datetime
import re

from flask import Flask, Response, abort, stream_with_context, render_template

from wake import base


app = Flask(__name__, static_folder='../build/static')


def entity_whitespace(html):
    def entity(match):
        return '&#' + str(ord(match.group())) + ';'
    return '<pre>' + re.sub('\s', entity, html) + '</pre>'


@app.after_request
def after(response):
    if response.mimetype != 'text/html':
        return response

    # minify html
    data = response.response
    def stream_minified():
        for html in data:
            html = re.sub(
                r"<pre>(.*?)</pre>",
                lambda m: entity_whitespace(m.group(1)),
                html,
                flags=re.DOTALL,
            )
            html = re.sub(r"\s+", " ", html)
            html = re.sub(r">\s*<", "><", html)
            html = re.sub(r">\s+", ">", html)
            html = re.sub(r"\s+<", "<", html)
            yield html

    response.headers.pop('Content-Length', None)
    response.response = stream_minified()

    return response


with app.open_resource('../build/static/main.css') as f:
{'fraction_non_alphanumeric': 0.15191545574636725, 'fraction_numerical': 0.0008806693086745927, 'mean_word_length': 2.2927536231884056, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '1402747', 'n_tokens_mistral': 712, 'n_tokens_neox': 689, 'n_words': 163}