擅长:python、mysql、java
<p>我为我的<a href="https://pypi.python.org/pypi/maildiff/1.1.1" rel="nofollow">maildiff</a>编写了一个简单的实现</p>
<pre><code>def getHtml(diffData):
""" This method convertes git diff data to html color code
"""
openTag = "<span style='font-size: .80em; color: "
openTagEnd = ";font-family: courier, arial, helvetica, sans-serif;'>"
nbsp = '&nbsp;&nbsp;&nbsp;&nbsp;'
return ''.join([("%s%s%s%s%s</span><br>" % (openTag, '#ff0000' if line.startswith('-') else ('#007900' if line.startswith('+') else '#000000'), openTagEnd, nbsp*line.count('\t') ,line)) for line in diffData])
</code></pre>
<p>看看吧。在</p>