Could not lex literal_block as "cpp"

195 views
Skip to first unread message

bradley...@gmail.com

unread,
Nov 16, 2022, 4:54:14 PM11/16/22
to sphinx-users
Suppose the following file is named soruce/temp.cpp:

    double f(
        double x // '(x)
    )
   {  return x; }

If I put the following command in my sphinx-quickstart source/index.rst file below the toctree command:

    .. literalinclude:: temp.cpp
       :language: cpp

and I execute the following command

    sphinx-build -b html source build
   
I get the following error message

   ...  sphinx/source/index.rst:14: WARNING: Could not lex literal_block as "cpp". ...

If, in temp.cpp,  I change the '(x) to (x) , the warning goes away and the file gets highlighted. It seems to me this change should not make any difference because it is inside a C++ comment.

bradley...@gmail.com

unread,
Nov 18, 2022, 9:33:06 AM11/18/22
to sphinx-users
The following test indicates this is a problem with sphinx and not pygments.
I copied and pastered source/temp.cpp into the pygments Demo https://pygments.org/demo/
with Language C++ and it works fine:

aziz khan

unread,
Nov 20, 2022, 4:21:11 AM11/20/22
to sphinx-users
Thanks, I'll check it out! 


--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sphinx-users/3114c31e-ffeb-4445-8fff-acb341b67bbfn%40googlegroups.com
.

Jean Abou Samra

unread,
Nov 27, 2022, 11:47:16 AM11/27/22
to sphinx...@googlegroups.com, bradley...@gmail.com
--


This is a bug that was fixed in recent versions of Pygments. Try upgrading (python3 -m pip install --upgrade pygments).


OpenPGP_signature

Muhammad Arslan Raza

unread,
Nov 27, 2022, 3:46:56 PM11/27/22
to sphinx...@googlegroups.com

Muhammad Arslan Raza

unread,
Nov 27, 2022, 3:47:35 PM11/27/22
to sphinx...@googlegroups.com

bradley...@gmail.com

unread,
Dec 2, 2022, 4:21:31 PM12/2/22
to sphinx-users
Thanks:
It appears that my system has automatically upgraded to pygments 2.13.0 and the problem is no longer there.
Reply all
Reply to author
Forward
0 new messages