__init__.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:munch-core 作者: crunchmail 项目源码 文件源码
def pretty_json_as_html(data, sort_keys=True):
    response = json.dumps(data, sort_keys=sort_keys, indent=2)
    # Truncate the data. Alter as needed
    response = response[:5000]

    # Get the Pygments formatter
    formatter = HtmlFormatter(style='colorful')

    # Highlight the data
    response = highlight(response, JsonLexer(), formatter)

    # Get the stylesheet
    style = "<style>" + formatter.get_style_defs() + "</style><br>"
    # Safe the output
    return mark_safe(style + response)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号