Skip to main content

Extend code-block directive for sphinx-revealjs builder

Project description

sphinx-revealjs-ext-codeblock

PyPI - Version PyPI - Python Version

Map standard Sphinx code-block options to reveal.js code attributes for the Sphinx revealjs builder.

It lets authors keep using standard directives such as code-block, literalinclude, :linenos:, :lineno-start:, and :emphasize-lines: instead of switching to reveal.js-specific directives.


Table of Contents

Installation

pip install sphinx-revealjs-ext-codeblock

Usage

conf.py

extensions = [
    "sphinx_revealjs",
    "sphinx_revealjs_ext_codeblock",
]

Specify revealjs_script_plugins & revealjs_css_files.

Line Numbers

.. code-block:: python
    :linenos:

    while True:
        print("Hello world!")
<pre>
  <code class="python" data-line-numbers>
while True:
    print(&quot;Hello world!&quot;)
  </code>
</pre>

See https://revealjs.com/code/#line-numbers-%26-highlights

Highlights

.. code-block:: python
    :emphasize-lines: 2

    while True:
        print("Hello world!")
<pre>
  <code class="python" data-line-numbers="2">
while True:
    print(&quot;Hello world!&quot;)
  </code>
</pre>

See https://revealjs.com/code/#line-numbers-%26-highlights

Literalinclude Line Number Start

.. literalinclude:: example.py
    :language: python
    :lines: 2-3
    :linenos:
    :lineno-start: 1
<pre>
  <code class="python" data-line-numbers data-ln-start-from="1">
print(&quot;two&quot;)
print(&quot;three&quot;)
  </code>
</pre>

See https://revealjs.com/code/#line-number-offset-4.2.0

Literalinclude Matched Line Numbers

.. literalinclude:: example.py
    :language: python
    :lines: 2-3
    :linenos:
    :lineno-match:
<pre>
  <code class="python" data-line-numbers data-ln-start-from="2">
print(&quot;two&quot;)
print(&quot;three&quot;)
  </code>
</pre>

License

sphinx-revealjs-ext-codeblock is distributed under the terms of the MIT license.

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

sphinx_revealjs_ext_codeblock-0.1.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sphinx_revealjs_ext_codeblock-0.1.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_revealjs_ext_codeblock-0.1.2.tar.gz.

File metadata

File hashes

Hashes for sphinx_revealjs_ext_codeblock-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9aca986c12aff0627a02610637d73a067f477ac4b6e87e4f26e724ef39275dd4
MD5 989be358b837d2cb519df6b2f3d456dd
BLAKE2b-256 f5b8824dd975ab8bfcd619bb15cccb314a9d80d4605f6eef67dd54c7d557bf5c

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_revealjs_ext_codeblock-0.1.2.tar.gz:

Publisher: publish.yml on ftnext/sphinx-revealjs-ext-codeblock

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sphinx_revealjs_ext_codeblock-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_revealjs_ext_codeblock-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 63a3131bbfecd26b47464b2ae6779438e6856e7c7cfff8b9957c7b3494a5d933
MD5 e585a1fe0dbdec7e9e3d60c92d479e78
BLAKE2b-256 05e36d2918452c08079fb0316da3e16836e46d0301f5384600d1b48becfe10fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_revealjs_ext_codeblock-0.1.2-py3-none-any.whl:

Publisher: publish.yml on ftnext/sphinx-revealjs-ext-codeblock

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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