Merge branch 'color_regex' of https://github.com/rcorre/qutebrowser into rcorre-color_regex

This commit is contained in:
Florian Bruhin 2016-05-04 07:04:40 +02:00
commit 46189977ae
2 changed files with 9 additions and 4 deletions

View File

@ -742,11 +742,13 @@ class QssColor(CssColor):
color_func_regexes: Valid function regexes.
"""
num = r'[0-9]{1,3}%?'
color_func_regexes = [
r'rgb\([0-9]{1,3}%?, [0-9]{1,3}%?, [0-9]{1,3}%?\)',
r'rgba\([0-9]{1,3}%?, [0-9]{1,3}%?, [0-9]{1,3}%?, [0-9]{1,3}%?\)',
r'hsv\([0-9]{1,3}%?, [0-9]{1,3}%?, [0-9]{1,3}%?\)',
r'hsva\([0-9]{1,3}%?, [0-9]{1,3}%?, [0-9]{1,3}%?, [0-9]{1,3}%?\)',
r'rgb\({},\s*{},\s*{}\)'.format(num, num, num),
r'rgba\({},\s*{},\s*{},\s*{}\)'.format(num, num, num, num),
r'hsv\({},\s*{},\s*{}\)'.format(num, num, num),
r'hsva\({},\s*{},\s*{},\s*{}\)'.format(num, num, num, num),
r'qlineargradient\(.*\)',
r'qradialgradient\(.*\)',
r'qconicalgradient\(.*\)',

View File

@ -913,12 +913,15 @@ class ColorTests:
('foo(1, 2, 3)', []),
('rgb(0, 0, 0)', [configtypes.QssColor]),
('rgb(0,0,0)', [configtypes.QssColor]),
('-foobar(42)', [configtypes.CssColor]),
('rgba(255, 255, 255, 255)', [configtypes.QssColor]),
('rgba(255,255,255,255)', [configtypes.QssColor]),
('hsv(359, 255, 255)', [configtypes.QssColor]),
('hsva(359, 255, 255, 255)', [configtypes.QssColor]),
('hsv(10%, 10%, 10%)', [configtypes.QssColor]),
('hsv(10%,10%,10%)', [configtypes.QssColor]),
('qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 white, '
'stop: 0.4 gray, stop:1 green)', [configtypes.QssColor]),
('qconicalgradient(cx:0.5, cy:0.5, angle:30, stop:0 white, '