import uuid
import re


def html_id_safe(text: str) -> str:
    """
    Makes a string that can be made into an HTML id and referenced easily
    """
    if not text:
        return str(uuid.uuid4())
    text = re.sub("[^0-9A-Za-z]", "-", text)
    text = re.sub("_{2,}", "-", text)
    if not text[0].isalpha():
        text = "x" + text
    return text