import re


def validate_output(output):
    """markdown validator

    fix number of new line and period newline.

    Args:
        output (str): input markdown text

    Returns:
        str: validated markdown
    """
    output = re.sub("\n+#", "\n\n#", output)
    output = re.sub("\n+$", "\n", output)
    return output