Example #1
0
def get_textifier(app=None, width=None):
    app = app or flask.current_app
    config = app.config

    cls = config["TEXTIFY_CLASS"]
    if isinstance(cls, compat.string_type):
        cls = util.find_object(cls)

    return cls
Example #2
0
def format_code(source, lexername=None, pre=False):
    from jinja2 import Markup

    app = flask.current_app
    lexer = None
    lexername = lexername or source.get("lang")

    if lexername:
        key = "%s_LEXER" % lexername.upper()
        if lexername and key in app.config:
            cls = app.config[key]
            if isinstance(cls, compat.string_type):
                cls = util.find_object(cls)
            lexer = cls()

    html = coloring.format_block(source, lexername=lexername, lexer=lexer,
                                 pre=pre)
    return Markup(html)