rouge-ruby / rouge

A pure Ruby code highlighter that is compatible with Pygments
https://rouge.jneen.net/
Other
3.3k stars 732 forks source link

python lexer not working as expected on docstrings #1999

Open nicoa opened 9 months ago

nicoa commented 9 months ago

Hey everybody, we observed the below problem in python lexing on gitlab:

Name of the lexer python

Code sample

def foo(
    bar,
    optional=None,
):
    """Docstring.

    Parameters
    ----------
    foo : str
        FOO.
    bar : str
        BAR!

    Example
    -------
    >>> import foo as bar
    >>>
    >>> asdf = '''
    >>> 
    >>> '''
    >>> bar()

    """
    # foobar
    print(foo)

Link to sample parsed: code sample.

Additional context The last two lines shouldn't be formatted as a comment, but rather as actual code. As seems as if either the ------ lines or the multiline comment using ' within the multiline comment using " seems to cause problems.