Skip to content

console lexer (BashSessionLexer) fails with quotes inside comments #1598

@j1elo

Description

@j1elo

Hi, I'm facing failures from Pygments while trying to build my project's documentation with Sphinx; after some analysis I discovered that the issue comes from single quotes (') being used within comments.

A block such as this one causes the issue:

.. code-block:: console

   # My project's build script
   echo "Hello World"

the code-block will try to parse its contents with the console lexer from Pygments, which fails:

WARNING: Could not lex literal_block as "console". Highlighting skipped.

Removing the single quote solves the issue:

.. code-block:: console

   # My projects build script
   echo "Hello World"

Pygments and Sphinx versions:

$ pip3 freeze | grep -i -e sphinx -e pygments
Pygments==2.7.2
Sphinx==3.3.0

I searched for "console" and "console quote" and couldn't find an already existing bug so I'm opening this one. Sorry if this is a duplicate (I somehow believe this bug must have been reported already, using a single quote in simple-form English comments seems too much of a common use case to have this bug unnoticed... but I haven't found anything)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions