Skip to content

Inline code is not syntax highlightedΒ #5157

@jessetan

Description

@jessetan

Problem

It is not possible to apply syntax highlighting to inline literals or code.

The docutils documentation provides a way to do this using the role directive to define a new role, based on the code role, but the resulting HTML contains classes like .keyword instead of classes like .highlight .k which are used in Pygments CSS.

Expected results

Sphinx to provide a code role that applies proper classes for Pygments to style.

There is an extension to add this, but it is from 2013 (so maybe out of date with recent Sphinx), and it does not contain code to generate highlighting in LaTeX.

Reproducible project / your project

.. role:: js(code)
    :language: js

This is inline code :js:`function a() { return 1; }`

Environment info

  • Sphinx version: 1.7.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions