Extensions for Sphinx which allow for substitutions.
Project description
Sphinx Substitution Extensions
Extensions for Sphinx which allow substitutions within code blocks.
Installation
Sphinx Substitution Extensions is compatible with Sphinx 7.2.0+ using Python 3.10+.
$ pip install Sphinx-Substitution-Extensions
rST setup
Add the following to conf.py to enable the extension:
extensions += ['sphinx_substitution_extensions']
Set the following variable in conf.py to define substitutions:
rst_prolog = """
.. |release| replace:: 0.1
.. |author| replace:: Eleanor
"""
This will replace |release| in the new directives with 0.1, and |author| with Eleanor.
Using substitutions in rST documents
code-block
This adds a :substitutions: option to Sphinx’s built-in code-block directive.
.. code-block:: bash
:substitutions:
echo "|author| released version |release|"
Inline :substitution-code:
:substitution-code:`echo "|author| released version |release|"`
substitution-download
:substitution-download:`|author|'s manuscript <|author|_manuscript.txt>`
MyST Markdown setup
Add the following to conf.py to enable the extension:
extensions += ['sphinx_substitution_extensions']
Set the following variables in conf.py to define substitutions:
myst_enable_extensions += ['substitution']
myst_substitutions = {
"release": "0.1",
"author": "Eleanor",
}
This will replace |release| in the new directives with 0.1, and |author| with Eleanor.
Using substitutions in MyST Markdown
code-block
This adds a :substitutions: option to Sphinx’s built-in code-block directive.
```{code-block} bash
:substitutions:
echo "|author| released version |release|"
```
Credits
ClusterHQ Developers
This package is largely inspired by code written for Flocker by ClusterHQ. Developers of the relevant code include, at least, Jon Giddy and Tom Prince.
Contributing
See CONTRIBUTING.rst.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sphinx_substitution_extensions-2024.8.6.tar.gz
.
File metadata
- Download URL: sphinx_substitution_extensions-2024.8.6.tar.gz
- Upload date:
- Size: 25.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0088b2f59967bb68dda3692e88daa12af78c6d3e6268375402b42f9d5fc9608b |
|
MD5 | 8d7e4fab7472b4b82dcc6c2ad9101435 |
|
BLAKE2b-256 | 51e528478a3cd206e850ac72eb764ef5acf7d2b0c658b78ae3faa206f6cfe9d7 |
File details
Details for the file sphinx_substitution_extensions-2024.8.6-py2.py3-none-any.whl
.
File metadata
- Download URL: sphinx_substitution_extensions-2024.8.6-py2.py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf459460008036e94ca4e488b3aa860d6ddfa4575b2a13a0551aca5df1ee04bf |
|
MD5 | f545146842a5c750e2a06859afd3a700 |
|
BLAKE2b-256 | 5bd0e3246fee409dd2c836ea6073520ff12845c79e7927352d599f257a75d7c1 |