Skip to main content

A Sphinx directive for literal blocks with emphasis

Project description

Sphinx awesome sampdirective

GitHub GitHub Workflow Status PyPI PyPI - Python Version Code Style

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

sphinxawesome-sampdirective-1.0.3.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file sphinxawesome-sampdirective-1.0.3.tar.gz.

File metadata

  • Download URL: sphinxawesome-sampdirective-1.0.3.tar.gz
  • Upload date:
  • Size: 5.1 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

Hashes for sphinxawesome-sampdirective-1.0.3.tar.gz
Algorithm Hash digest
SHA256 e4da5181109336eb018a27b899a4b98eb2f2c2289072a16a2c0be8e0dece4809
MD5 a9f12d7003a077288cbb11d6a435d4b6
BLAKE2b-256 59b1c5c778f84deb97b8d76f13b81c5c877f2eed6c596e28a4be42771eed110c

See more details on using hashes here.

File details

Details for the file sphinxawesome_sampdirective-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinxawesome_sampdirective-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8dccf8a79d475ca9985711a841a22ee3f8f21a6d3e9e7fc3eabcdea84878e827
MD5 f7a4f25b4c838a161cec1ae1d276878c
BLAKE2b-256 c96a5064069dc630fb8b0bf79959b156144689067f7469b9e4ef52e059efb72f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page