fixed regexp bug in font-size parser

This commit is contained in:
Sanj 2011-06-21 02:55:55 +05:30
parent 8fe621d14d
commit 671641495f

View File

@ -8,7 +8,6 @@ def make_really_big(value, m):
>>>make_really_big("40px", 4)
>>>160px
"""
m = m + 1
v = str(value).strip()
if v[-2:] == 'px':
no = int(value.replace("px", "")) * m
@ -21,12 +20,13 @@ def parse_html(value, m):
>>>parse_html("foo is 20px", 4)
>>>"foo is 80px"
"""
p = "[0-9][0-9]?px"
p = "font\-size: [0-9][0-9]?px"
matches = re.findall(p, value)
for match in matches:
val = int(match.replace("px", ""))
s = match.replace("font-size: ", "")
val = int(s.replace("px", ""))
new_val = int(round(val * m))
r = str(new_val) + "px"
r = "font-size: " + str(new_val) + "px"
value = value.replace(match, r)
return value