def mkdown_h(text, level, link=None):
    """
    Generates the markdown syntax for a header of a certain level.
    """
    if level == 1:
        return '\n' + ('<a name="{}"></a>'.format(link) if link else '') + text + '\n' \
                + '='*len(text)
    elif level == 2:
        return '\n' + ('<a name="{}"></a>'.format(link) if link else '') + text + '\n' \
                + '-'*len(text)
    else:
        return '\n' + '#'*level + ' ' + ('<a name="{}"></a>'.format(link) if link else '') + text