Skip to content

code directive doesn't treat emphasize-lines option the same way as code-block  #14411

@parulin

Description

@parulin

Describe the bug

When using the code directive instead of code-block, the :emphasize-lines: option produces an error:

/tmp/sphinxbug/index.rst:1: ERROR: Error in "code" directive:
unknown option: "emphasize-lines".

.. code:: rst
   :emphasize-lines: 1

   test [docutils]

sourcecode directives work.

How to Reproduce

Just use this as your index.rst and try to build the docs:

.. code:: rst
   :emphasize-lines: 1

   test

Adding -block after code fix the issue.

Environment Information

Platform:              linux; (Linux-6.18.15-1.qubes.fc41.x86_64-x86_64-with-glibc2.36)
Python version:        3.14.4 (main, Apr 14 2026, 14:26:14) [Clang 22.1.3 ])
Python implementation: CPython
Sphinx version:        9.1.0
Docutils version:      0.22.4
Jinja2 version:        3.1.6
Pygments version:      2.20.0

Sphinx extensions

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions