def anchor_name_from_token(anchor_token):
    """Get anchor name from string or uri token."""
    if anchor_token[0] == 'string' and anchor_token[1].startswith('#'):
        return anchor_token[1][1:]
    elif anchor_token[0] == 'url' and anchor_token[1][0] == 'internal':
        return anchor_token[1][1]
Get anchor name from string or uri token.
weasyprint/css/targets.py