Last active
February 7, 2018 23:59
-
-
Save sanfx/8620493 to your computer and use it in GitHub Desktop.
convert git diff to color HTML for embed to webpage or email using python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ' ' | |
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]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment