Skip to content

Highlighting appears to be lost for code-blocks from markdown sources with Sphinx v8.2.0+/e65bbb96a and myst_parser #13207

@jfbu

Description

@jfbu

Describe the bug

After updating Sphinx on Jan 4, 2025, it seems highlighting for code-blocks originating in markdown sources is not applied (myst_parser is used). I first observed this in a more complicated way in a big project with extra hacks to customize rendering, but could reduce it to a fairly minimal one using only myst_parser and highlight_language (the latter because due to original code-blocks use latex but the problem is not related to the latex builder).

How to Reproduce

Unzip the small attached project (see #13207 (comment)) and execute make html O="-E" with current release Sphinx 8.1.0 or a checkout of current dev at at least Sphinx v8.2.0+/e65bbb96a. In the latter case, highlighting is lost for the code in markdown file. With parent commit Sphinx v8.2.0+/c7eaf175e, the highlighting is there.

Environment Information

Sphinx version: 8.2.0+/e65bbb96a
Python version: 3.12.3 (CPython)
Docutils version: 0.21.2 
Pygments version: 2.18.0
Jinja2 version: 3.1.4
MySTparser version: 3.0.1

UPDATE: the problem also shows with myst-parser 4.0.0.

Sphinx extensions

extensions = [
    'myst_parser',
]

Additional context

Relates #13151

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions