Skip to content

🐛 Keep captioned code blocks in tab-set-code - #318

Open
abhishekcpp007 wants to merge 1 commit into
executablebooks:mainfrom
abhishekcpp007:fix/tab-set-code-captioned-blocks
Open

abhishekcpp007 wants to merge 1 commit into
executablebooks:mainfrom
abhishekcpp007:fix/tab-set-code-captioned-blocks

Conversation

@abhishekcpp007

Copy link
Copy Markdown

A code-block or literalinclude with :caption: is wrapped by Sphinx in a container (literal-block-wrapper), so tab-set-code sees a non-literal_block child, warns and drops it:

.. tab-set-code::

    .. code-block:: python
        :caption: example.py

        print("hi")

    .. code-block:: javascript

        console.log("hi")

On main this gives WARNING: All children of a 'tab-code-set' should be a 'literal_block' [design.tab_code] and only the JavaScript tab. The MyST form does the same.

Now the language is read from the wrapped literal_block, and the wrapper itself goes into the tab, so the caption and any :name: target are kept.

Added test_tab_set_code_with_caption next to test_tab_set_code_with_target.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant