Skip to content

basic theme: CSS spacing for code blocks with captions and line numbers#7482

Merged
tk0miya merged 2 commits intosphinx-doc:3.xfrom
mgeier:basic-code-blocks
Apr 15, 2020
Merged

basic theme: CSS spacing for code blocks with captions and line numbers#7482
tk0miya merged 2 commits intosphinx-doc:3.xfrom
mgeier:basic-code-blocks

Conversation

@mgeier
Copy link
Copy Markdown
Contributor

@mgeier mgeier commented Apr 14, 2020

I'm not sure whether I got all the details right, but I think it's definitely an improvement.

Example document:

Normal code block:

.. code-block:: python

    print('Hello, wooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooorld!')

With line numbers:

.. code-block:: python
    :linenos:

    print('Hello, wooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooorld!')

With caption:

.. code-block:: python
    :caption: Caption

    print('Hello, wooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooorld!')

With caption and line numbers:

.. code-block:: python
    :caption: Caption
    :linenos:

    print('Hello, wooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooorld!')

With html_theme = 'basic', this previously looked like:

image

After this PR, it looks like:

image

@mgeier
Copy link
Copy Markdown
Contributor Author

mgeier commented Apr 14, 2020

I forgot something and added a new commit: c795793 (which can be squashed with the previous).

This fixes highlighted code lines:

.. code-block:: python
    :emphasize-lines: 3,5

    def some_function():
        interesting = False
        print('This line is highlighted.')
        print('This one is not...')
        print('...but this one is.')

Before:

image

After:

image

@tk0miya tk0miya added builder:html type:proposal a feature suggestion labels Apr 15, 2020
@tk0miya tk0miya added this to the 3.1.0 milestone Apr 15, 2020
Copy link
Copy Markdown
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

builder:html type:proposal a feature suggestion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants