Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code blocks use short pygments class names, but inline code uses long ones #7958

Closed
cpitclaudel opened this issue Jul 14, 2020 · 2 comments
Closed

Comments

@cpitclaudel
Copy link
Contributor

Describe the bug

This error was originally reported on https://stackoverflow.com/questions/21591107/sphinx-inline-code-highlight

code-block directives use short pygments class names. Inline code snippets (the code role), on the other hand, use long Pygments class names. As a result, inline code snippets are not properly highlighted.

To Reproduce

$ mkdir /tmp/sphinx
$ cd /tmp/sphinx
$ sphinx-quickstart
…
$ # edit index.rst as shown below
$ tail index.rst
* :ref:`search`

.. role:: bash(code)
   :language: bash

Test inline: :bash:`export FOO="bar"`.

.. code-block:: bash

    export FOO="bar"
$ make html
Makefile:20: warning: undefined variable 'O'
…
The HTML pages are in _build/html.
$ firefox _build/html/index.html 

Expected behavior
Both code snippets should be highlighted. Insetad, only the code block is highlighted. The inlien snippet has pygments classes applied, but they use long class names, and so they don't match the syntax-highlighting CSS rules, which use short class names.

Environment info

  • OS: GNU/Linux (Linux Mint 20)
  • Python version: Python 3.8.2
  • Sphinx version: sphinx-build 3.0.4
  • Sphinx extensions: None
  • Extra tools: Firefox
@tk0miya
Copy link
Member

tk0miya commented Jul 23, 2020

Thank you for reporting. But that was already reported at #5157. So I'm closing this as dup.

@cpitclaudel
Copy link
Contributor Author

Ouch, sorry for the noise !

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants