sphinx-revealjs-ext-codeblock 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ # SPDX-FileCopyrightText: 2025-present ftnext <takuyafjp+develop@gmail.com>
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ __version__ = "0.1.0"
@@ -0,0 +1,50 @@
1
+ # SPDX-FileCopyrightText: 2025-present ftnext <takuyafjp+develop@gmail.com>
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ from docutils.nodes import literal_block, section
5
+ from sphinx.util.typing import ExtensionMetadata
6
+ from sphinxcontrib.kasane import TranslatorSetUp
7
+ from sphinxcontrib.kasane.conditions import BuilderNameCondition
8
+ from sphinxcontrib.kasane.inheritance import MixinDynamicInheritance
9
+
10
+ from sphinx_revealjs_ext_codeblock.__about__ import __version__
11
+
12
+
13
+ class ExtendedLiteralRevealjsSlideTranslatorMixin:
14
+ def visit_literal_block(self, node: literal_block):
15
+ lang = node["language"]
16
+ # add section id as data-id if it is exists
17
+ if "data-id" in node:
18
+ self.body.append(f"<pre data-id=\"{node['data-id']}\">")
19
+ elif isinstance(node.parent, section) and len(node.parent["ids"]):
20
+ self.body.append(f"<pre data-id=\"{node.parent['ids'][0]}\">")
21
+ else:
22
+ self.body.append("<pre>")
23
+ self.body.append(f'<code data-trim data-noescape class="{lang}"')
24
+ # use the emphasize-lines directive to create line for line animations
25
+ if "data-line-numbers" in node:
26
+ self.body.append(f" data-line-numbers=\"{node['data-line-numbers']}\"")
27
+ # Tweak https://github.com/attakei/sphinx-revealjs/compare/master...ftnext:sphinx-revealjs:code-block-emphasize-lines
28
+ elif highlight_args := node.get("highlight_args"):
29
+ if "hl_lines" in highlight_args:
30
+ highlight_lines = ",".join(str(num) for num in highlight_args["hl_lines"])
31
+ self.body.append(f' data-line-numbers="{highlight_lines}"')
32
+ # Tweak End
33
+ elif node["linenos"]:
34
+ self.body.append(" data-line-numbers")
35
+ if "data-ln-start-from" in node:
36
+ self.body.append(f" data-ln-start-from=\"{node['data-ln-start-from']}\"")
37
+ if "data-line-numbers" not in node:
38
+ self.body.append(" data-line-numbers")
39
+ self.body.append(">")
40
+
41
+
42
+ def setup(app) -> ExtensionMetadata:
43
+ condition = BuilderNameCondition("revealjs")
44
+ inheritance = MixinDynamicInheritance(
45
+ ExtendedLiteralRevealjsSlideTranslatorMixin,
46
+ "ExtendedLiteralRevealjsSlideTranslator",
47
+ )
48
+ app.connect("builder-inited", TranslatorSetUp(inheritance, condition))
49
+
50
+ return ExtensionMetadata(version=__version__)
@@ -0,0 +1,114 @@
1
+ Metadata-Version: 2.4
2
+ Name: sphinx-revealjs-ext-codeblock
3
+ Version: 0.1.0
4
+ Summary: Extend code-block directive for sphinx-revealjs builder
5
+ Project-URL: Documentation, https://github.com/ftnext/sphinx-revealjs-ext-codeblock#readme
6
+ Project-URL: Issues, https://github.com/ftnext/sphinx-revealjs-ext-codeblock/issues
7
+ Project-URL: Source, https://github.com/ftnext/sphinx-revealjs-ext-codeblock
8
+ Author-email: ftnext <takuyafjp+develop@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Framework :: Sphinx
13
+ Classifier: Framework :: Sphinx :: Extension
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Documentation
25
+ Classifier: Topic :: Documentation :: Sphinx
26
+ Classifier: Topic :: Software Development :: Documentation
27
+ Classifier: Topic :: Text Processing :: Markup :: HTML
28
+ Requires-Python: >=3.9
29
+ Requires-Dist: sphinx-revealjs
30
+ Requires-Dist: sphinxcontrib-extdevhelper-kasane
31
+ Description-Content-Type: text/markdown
32
+
33
+ # sphinx-revealjs-ext-codeblock
34
+
35
+ [![PyPI - Version](https://img.shields.io/pypi/v/sphinx-revealjs-ext-codeblock.svg)](https://pypi.org/project/sphinx-revealjs-ext-codeblock)
36
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/sphinx-revealjs-ext-codeblock.svg)](https://pypi.org/project/sphinx-revealjs-ext-codeblock)
37
+
38
+ Extend `code-block` directive for Sphinx `revealjs` builder.
39
+
40
+ -----
41
+
42
+ ## Table of Contents
43
+
44
+ - [Installation](#installation)
45
+ - [Usage](#usage)
46
+ - [License](#license)
47
+
48
+ ## Installation
49
+
50
+ ```console
51
+ pip install sphinx-revealjs-ext-codeblock
52
+ ```
53
+
54
+ ## Usage
55
+
56
+ conf.py
57
+
58
+ ```python
59
+ extensions = [
60
+ "sphinx_revealjs",
61
+ "sphinx_revealjs_ext_codeblock",
62
+ ]
63
+ ```
64
+
65
+ Specify `revealjs_script_plugins` & `revealjs_css_files`.
66
+
67
+ * https://sphinx-revealjs.readthedocs.io/en/stable/configurations/#confval-revealjs_script_plugins
68
+ * https://sphinx-revealjs.readthedocs.io/en/stable/configurations/#confval-revealjs_css_files
69
+
70
+ ### Line Numbers
71
+
72
+ ```rst
73
+ .. code-block:: python
74
+ :linenos:
75
+
76
+ while True:
77
+ print("Hello world!")
78
+ ```
79
+
80
+ ```html
81
+ <pre>
82
+ <code class="python" data-line-numbers>
83
+ while True:
84
+ print(&quot;Hello world!&quot;)
85
+ </code>
86
+ </pre>
87
+ ```
88
+
89
+ See https://revealjs.com/code/#line-numbers-%26-highlights
90
+
91
+ ### Highlights
92
+
93
+ ```rst
94
+ .. code-block:: python
95
+ :emphasize-lines: 2
96
+
97
+ while True:
98
+ print("Hello world!")
99
+ ```
100
+
101
+ ```html
102
+ <pre>
103
+ <code class="python" data-line-numbers="2">
104
+ while True:
105
+ print(&quot;Hello world!&quot;)
106
+ </code>
107
+ </pre>
108
+ ```
109
+
110
+ See https://revealjs.com/code/#line-numbers-%26-highlights
111
+
112
+ ## License
113
+
114
+ `sphinx-revealjs-ext-codeblock` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,6 @@
1
+ sphinx_revealjs_ext_codeblock/__about__.py,sha256=FAMBQ59-ourcMTsagzlZFwAmV4c4oBseBLGJPa-HYaI,131
2
+ sphinx_revealjs_ext_codeblock/__init__.py,sha256=1ZMdZXEIiFVAPSzGz1ewnPDxRtCDESLfH4SsjpghI40,2351
3
+ sphinx_revealjs_ext_codeblock-0.1.0.dist-info/METADATA,sha256=1sJtsjqY6SJ2Y-aNQI_p1tLC35l1cSNcqWF2IhRg84M,3121
4
+ sphinx_revealjs_ext_codeblock-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
+ sphinx_revealjs_ext_codeblock-0.1.0.dist-info/licenses/LICENSE,sha256=KkcnYlzXOSv9r5vZOx9y_VY3PCcQxLhX8zy83xtkaOs,1063
6
+ sphinx_revealjs_ext_codeblock-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 nikkie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.