def name_to_hex(name, spec=u'<STR_LIT>'):
if spec not in SUPPORTED_SPECIFICATIONS:<EOL><INDENT>raise ValueError(SPECIFICATION_ERROR_TEMPLATE.format(spec=spec))<EOL><DEDENT>normalized = name.lower()<EOL>hex_value = {u'<STR_LIT>': CSS2_NAMES_TO_HEX,<EOL>u'<STR_LIT>': CSS21_NAMES_TO_HEX,<EOL>u'<STR_LIT>': CSS3_NAMES_TO_HEX,<EOL>u'<STR_LIT>': HTML4_NAMES_TO_HEX}[spec].get(normalized)<EOL>if hex_value is None:<EOL><INDENT>raise ValueError(<EOL>u"<STR_LIT>".format(<EOL>name=name, spec=spec<EOL>)<EOL>)<EOL><DEDENT>return hex_value<EOL>
Convert a color name to a normalized hexadecimal color value.

The optional keyword argument ``spec`` determines which
specification's list of color names will be used; valid values are
``html4``, ``css2``, ``css21`` and ``css3``, and the default is
``css3``.

When no color of that name exists in the given specification,
``ValueError`` is raised.