blob: d9e45a2312cf8c37bf466a18b0061963807905dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/usr/bin/python
import fileinput
import re
def hexrepl(match):
value = int(match.group(2), 16) - 13
if value < 0:
value = 0
return match.group(1) + hex(value)[2:]
def rgbrepl(match):
value = int(match.group(2)) - 13
if value < 0:
value = 0
return match.group(1) + str(value)
for line in fileinput.input():
newline = re.sub(r"(#[0-9a-fA-F]{4})([0-9a-fA-F]{2})", hexrepl, line)
newline = re.sub(r"(rgba\([0-9]+, ?[0-9]+, ?)([0-9]+)", rgbrepl, newline)
print(newline, end="")
|