def _parse_styles(style_text, specificity):
    """Parse a style string into a dictionary {style_key: (style_value, specificity)}."""

    return dict([(k.strip(), (v.strip(), specificity))
                 for k, v in [x.strip().split(':', 1)
                              for x in style_text.split(';') if x.strip()]])