A Sphinx directive for literal blocks with emphasis
Project description
Sphinx awesome sampdirective
This Sphinx extension provides a new directive samp
which works much like the
interpreted text role
samp.
This extension can be used to markup placeholder variables in code blocks.
Installation
Install the extension:
pip install sphinxawesome-sampdirective
This Sphinx extension should work with Python versions newer than 3.6 and recent Sphinx releases.
Configuration
To enable this extension in Sphinx, add it to the list of extensions in the Sphinx
configuration file conf.py
:
extensions = ["sphinxawesome.sampdirective"]
Use
Include the directive in your documents:
.. samp::
$ echo {USERNAME}
USERNAME
will become an emphasized node. In many outputs, it will be rendered as
USERNAME
. For example, in HTML, the above example will be rendered as:
<pre>
<span class="gp">$</span> echo <em class="var">USERNAME</em>
</pre>
You can then control the style of the emphasized element with the .var
class in CSS.
If the code block begins with a prompt character (#
, $
, or ~
), they will be marked
up as well. The style for the prompt character is provided by the pygments
syntax
highlighting module.
The Sphinx awesome theme includes
styling for the samp
directive by default.
Caveat
This extension does not provide full syntax highlighting. It is currently not possible to have code blocks with both markup and syntax highlighting. You have to choose between the following:
- If you need to render markup, for example links, or bold or italic text, choose the
parsed-literal
directive. - If you just want to highlight a placeholder variable, use the
samp
directive provided by this extension. - If you need full syntax highlighting, use the
code-block
directive.
Project details
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 sphinxawesome-sampdirective-1.0.2.tar.gz
.
File metadata
- Download URL: sphinxawesome-sampdirective-1.0.2.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.9 CPython/3.8.3 Linux/5.3.0-1028-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b05353faa4cb5b6faaacd5c56d772d1bc0d59aa836dbead9374002df5a4e32b3 |
|
MD5 | 64bc9299ce1da6f0958d12c4ff104887 |
|
BLAKE2b-256 | 65be1562d87db6220b224f6836b46a54ced394adb38090977761d7bdb06ed0e0 |
File details
Details for the file sphinxawesome_sampdirective-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: sphinxawesome_sampdirective-1.0.2-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.9 CPython/3.8.3 Linux/5.3.0-1028-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 935782f9e8a1389f108c9625f3ce21d781159d3998f4859a8f042974e1321f13 |
|
MD5 | bd7dd4685780cc8fd050c1b7bd66da36 |
|
BLAKE2b-256 | 4ad47f56af6790a0210594d99ab3c9089ee5a809d013061de375d9cdcb1f1f1b |