def setup(app, cfg):
    global formatter
    formatter = HtmlFormatter(style=cfg.get('style', 'tango'))
    directives.register_directive('sourcecode', Pygments)
    directives.register_directive('code-block', Pygments)
    
    @app.route(cfg.get('css_file_route', "/static/pygments.css"))
    def pygments_css():
        etag = sha1(str(formatter.style)).hexdigest()
        if request.headers.get('If-None-Match') == etag:
            return "", 304
        else:
            res = make_response(formatter.get_style_defs())
            res.mimetype = "text/css"
            res.headers['ETag'] = etag
            return res
    
    @app.before_request
    def inject_pygments_css():
        if url_for('pygments_css') not in app.config['STYLESHEETS']:
            app.config['STYLESHEETS'].append(url_for('pygments_css'))
dataset/ETHPy150Open jarus/flask-rst/flaskrst/modules/pygments.py/setup/original