import re


def increment_headings(markdown):
    """Increment all the heading levels of a markdown string, if it contains level-one heading.
    This also normalizes heading lines "#\s*title" -> "# title"

    Note: this doesn't know not to look in fenced blocks
    """
    # Normalize the '## ' spacing
    markdown = re.sub(r"^(#+)\s*", r"\1 ", markdown, 0, re.M)
    # If there's an H1, increment all the Hn's
    if re.compile(r"^# ", re.M).search(markdown):
        markdown = re.sub(r"^(#+)", r"\1# ", markdown, 0, re.M)
    return markdown