Skip to content

Why deprecate the html_codeblock_linenos_style option? #10265

Closed
@2bndy5

Description

@2bndy5

Is your feature request related to a problem? Please describe.
We've been porting the mkdocs-material theme to sphinx-immaterial, and found the the mkdocs-material theme uses tables to represent literal code blocks with line numbers. With Sphinx's default setting

html_codeblock_linenos_style = "inline"

We found a few problems:

  1. The line numbers are copied to the clipboard when using clipboard.js.
  2. The CSS inherited from mkdocs-material cannot distinguish line numbers from the rest of the literal code block. Thus no intended CSS gets used.
  3. Line numbers scroll horizontally with the rest of the literal code block. Ideally, we expect the line numbers to be statically positioned while horizontally scrolling the rest of the literal code block.

Describe the solution you'd like
Please don't deprecate the html_codeblock_linenos_style config option in Sphinx v6.0.

Describe alternatives you've considered
For now, we're thinking of having the sphinx-immaterial theme assert the option to use

html_codeblock_linenos_style = "table"

When/If Sphinx v6.0 removes the option, we're going to have to overwrite the visit_literal_block() to restore this functionality.

Additional context

I talked with @tk0miya at the Sphinx(jp) hack-a-thon event, and we discussed that there is no need to leave table output in the future.

I've read #7879 (comment), but I don't see any good rationality to deem the option deprecated. The sphinx builtin themes aren't the only themes that supply their own CSS (we don't inherit any CSS from sphinx builtin themes). If writing CSS for code blocks with line numbers (using "table") is too complex, then leave it to the theme designers to choose how to set the option - don't deprive them of the option all together.

We're not as flexible as we'd like to be concerning CSS changes. This is because we need to minimize the possible merge conflicts when merging in updates from the mkdocs-material theme. Same reason goes for using clipboard.js instead of executablebooks/sphinx-copy-button extension (though this isn't as strict a requirement as keeping the CSS unaltered).

Original issue for the sphinx-immaterial theme is jbms/sphinx-immaterial#26

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:enhancementenhance or introduce a new feature

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions