import re


def lower_reference_names(rst):
    """Lowercase reference names

    Reference names are converted to lowercase when HTML is rendered
    from reST. Here they are lowercased for consistency in the rst
    document.

    .. _Target-No.1: -> .. _target-no.1:
    """
    rst = re.sub(r'^\.\. _[^:]+:$', lambda m: m.group(0).lower(),
                 rst, flags=re.M)
    return rst