from xml.sax.saxutils import escape


def _make_in_prompt(prompt_template, number=None):
    """ Given a prompt number, returns an HTML In prompt.
    """
    try:
        body = prompt_template % number
    except TypeError:
        # allow in_prompt to leave out number, e.g. '>>> '
        body = escape(prompt_template)
    return '<span class="in-prompt">%s</span>' % body