sphinx_parsed_codeblock
Sphinx extension adding a directive for a parsed code-block.
Intro
Have you ever tried to use markup inside a code-block? For example, to create a link from inside some code?
Disappointingly, there is no such functionality in sphinx - a choice must be made between the markup
(via the parsed-literal
directive) and the syntax highlighting (via the
code-block/sourcecode/code
directive). However, with this extension, that is no longer the case! A new directive, parsed-code-block, is provided,
which mixes the functionality of both, providing support for markup inside syntax-highlighted code-block.
Quickstart
The extension can be installed via pip:
pip install sphinx_parsed_codeblock
Then, by including the extension in Sphinx's conf.py:
extensions = ['sphinx_parsed_codeblock']
the new directive can be used anywhere in the RST documentation:
.. parsed-code-block:: yaml
foo:
italics: *"string"*
bold: **12345**
``literal: null``
link: :ref:`true<doc-top>`
The parsed-code-block directive is a subclass of the default code-block directive and so can be used with all
the same options and arguments:
.. parsed-code-block:: yaml
:linenos:
:lineno-start: 5
:emphasize-lines: 2, 4
:caption: test
:name: test-code-block
foo:
italics: *"string"*
bold: **12345**
``literal: null``
link: :ref:`true<doc-top>`
For more information, see documentation.
Functionality
This extension provides one new directive - parsed-code-block - which allows for RST markup to be used
inside a syntax-highlighted code-block. All inline markup is supported:
- italics (
*italics*) - bold (
**bold**) literal(``literal``)- link (
:ref:`link`) - etc.
though higher-level RST such as directives will not be parsed.
Supported Output Formats
- HTML
For all other formats, the parsed-code-block is treated the same as parsed-literal, so
output will be produced, but without syntax highlighting.
Contributing
The project is considered generally feature complete, but if anything is not working as expected, please open an issue!
Metadata
Release files for sphinx-parsed-codeblock 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sphinx_parsed_codeblock-1.0.1.tar.gz | 46.9 kB | Without provenance | Details for sphinx_parsed_codeblock-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sphinx_parsed_codeblock-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for sphinx_parsed_codeblock-1.0.1-py3-none-any.whl |
Total release size: 80.5 kB
Release files / sphinx_parsed_codeblock-1.0.1.tar.gz
| Download URL | sphinx_parsed_codeblock-1.0.1.tar.gz |
|---|---|
| Size | 46.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4fc5528b76a089c10fbf8e3f292d449579f1d2edcf3bccdd8936df542bb05a59
|
|
BLAKE2b-256 checksum How to use checksums |
e6fe48aa0c9346aa2b103e48209160a2ed0589e4101c2c30caf603eb8de77b43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Release files / sphinx_parsed_codeblock-1.0.1-py3-none-any.whl
| Download URL | sphinx_parsed_codeblock-1.0.1-py3-none-any.whl |
|---|---|
| Size | 33.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1089ba2671edc00fa906b31148fadfc87e40422f012cc79d9efe1e62cee9713e
|
|
BLAKE2b-256 checksum How to use checksums |
2fd54797a25245a184f60e773430e34a9b4e48138c916ad4a6a2b1052a25c64c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Security for sphinx-parsed-codeblock 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.