mail_formater.py 文件源码

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

项目:DualisWatcher 作者: LucaVazz 项目源码 文件源码
def _format_code(html_code):
    # syntax highlighting:
    code_highlighted = highlight(html_code, HtmlLexer(), HtmlFormatter(style='monokai', noclasses=True))
    # add formatting for diff-markers:
    common_diff_style = ' margin-right: 3px; padding-right: 7px; padding-left: 7px;'
    code_formatted = code_highlighted \
        .replace('[-', '<span style="background: #71332c;' + common_diff_style + '">') \
        .replace('-]', '</span>') \
        .replace('{+', '<span style="background: #2e4d28;' + common_diff_style + '">') \
        .replace('+}', '</span>')

    # wrap in general layout:
    code_wrapped = '<div style="color: #efefef; margin: 3px; margin-left: 17px;line-height: 150%%;">%s</div>'\
                   %(code_formatted)

    return code_wrapped
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号