def add_in_prompt(text, prompt_no):
    """Add the In [1]: prompts to a block of code."""
    if prompt_no is None:
        prompt = 'In [ ]: '
    else:
        prompt = 'In [%d]: ' % prompt_no
    margin = ' ' * len(prompt)
    colour_prompt = '<span color="#000080">%s</span>' % prompt
    lines = text.splitlines(keepends=True)
    return colour_prompt + margin.join(lines)
