| 70 | |
| 71 | const hexColorRegEx = /\s*#((?:[0-9A-F]{8})|(?:[0-9A-F]{6})|(?:[0-9A-F]{4})|(?:[0-9A-F]{3}))\s*/giy; |
| 72 | export function parseHexColor(text: string, start = 0): Parsed<Color> { |
| 73 | hexColorRegEx.lastIndex = start; |
| 74 | const result = hexColorRegEx.exec(text); |
| 75 | if (!result) { |
| 76 | return null; |
| 77 | } |
| 78 | const end = hexColorRegEx.lastIndex; |
| 79 | return { start, end, value: new Color('#' + result[1]) }; |
| 80 | } |
| 81 | |
| 82 | const cssColorRegEx = /\s*((?:rgb|rgba|hsl|hsla|hsv|hsva)\([^\(\)]*\))/gy; |
| 83 | export function parseCssColor(text: string, start = 0): Parsed<Color> { |