def simple_text_to_html(content):
    """
    Puts <p> around lines of text, creates <ul> / <li> for lines that begin
    with *

    >>> text = "Simple line of text."
    >>> print(simple_text_to_html(text))
    <p>Simple line of text.</p>
    <BLANKLINE>
    >>>

    >>> text = '''Simple line of text.
    ...
    ... And another line.'''
    >>> print(simple_text_to_html(text))
    <p>Simple line of text.</p>
    <p>And another line.</p>
    <BLANKLINE>
    >>>

    >>> text = '''Simple line of text followed by a list:
    ...
    ... * with an item
    ... * and another item'''
    >>> print(simple_text_to_html(text))
    <p>Simple line of text followed by a list:</p>
    <ul>
    <li>with an item</li>
    <li>and another item</li>
    </ul>
    <BLANKLINE>
    >>>

    >>> text = '''
    ...
    ...
    ...
    ...
    ... '''
    >>> print(simple_text_to_html(text))
    <BLANKLINE>
    >>>

    >>> text = '''A paragraph followed by a list:
    ... * item A
    ... * item B
    ... Followed by another paragraph and then two lists:
    ... * item alpha
    ... * item beta
    ...
    ... * item gamma
    ... * item delta'''
    >>> print(simple_text_to_html(text))
    <p>A paragraph followed by a list:</p>
    <ul>
    <li>item A</li>
    <li>item B</li>
    </ul>
    <p>Followed by another paragraph and then two lists:</p>
    <ul>
    <li>item alpha</li>
    <li>item beta</li>
    </ul>
    <ul>
    <li>item gamma</li>
    <li>item delta</li>
    </ul>
    <BLANKLINE>
    >>>
    """

    current_tag = None
    output = ""

    for line in content.split('\n'):
        # strip precending empty characters
        re.sub('^\s', '', line)

        if not line:
            # Ignore empty lines, but if in a list, close the list.
            if current_tag == 'ul':
                output += "</ul>\n"
                current_tag = None
        else:
            # * lines are list items, create list if necessary
            if line[0] == '*':
                if current_tag != 'ul':
                    output += "<ul>\n"
                    current_tag = 'ul'
                output += "<li>%s</li>\n" % line[2:]
            # everything else, for now, is a paragraph
            else:
                if current_tag == 'ul':
                    output += '</ul>\n'
                    current_tag = None
                output += line % '<p>%s</p>\n'

    # if we're done with the content but still have an open list, close it
    if current_tag == 'ul':
        output += '</ul>\n'

    return output
dataset/ETHPy150Open willowtreeapps/tango-core/tango/tools/__init__.py/simple_text_to_html/swapped operands of `%`