Merge pull request #23 from groggydice/rgb

append pango code to message about color spec requiring manual fix
This commit is contained in:
Alexander van Gessel 2013-06-08 08:06:13 -07:00
commit ce8e60bdda

View File

@ -782,8 +782,16 @@ def pangoize(message, filename, line):
amper = message.find('&')
if message[amper:amper+1].isspace():
message = message[:amper] + "&" + message[amper+1:]
if re.search("<[0-9]+,[0-9]+,[0-9]+>", message):
print '"%s", line %d: color spec in line requires manual fix.' % (filename, line)
rgb = re.search("(?:<|&lt;)([0-9]+),([0-9]+),([0-9]+)(>|&gt;)", message)
if rgb:
r = int(rgb.group(1))
g = int(rgb.group(2))
b = int(rgb.group(3))
if ( r or g or b) > 255:
print '"%s", line %d: RGB color value over 255 requires manual fix (%s).' % (filename, line, rgb.group())
else:
hexed = hex(r).replace('0x', '0')[-2:] + hex(g).replace('0x', '0')[-2:] + hex(b).replace('0x', '0')[-2:]
print '"%s", line %d: color spec (%s) requires manual fix (<span color=\'#%s\'>, </span>).' % (filename, line, rgb.group(), hexed)
# Hack old-style Wesnoth markup
for (oldstyle, newstart, newend) in pango_conversions:
if oldstyle not in message: