sphinx-revealjs-ext-codeblock 0.1.0__tar.gz
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.
- sphinx_revealjs_ext_codeblock-0.1.0/.github/workflows/publish.yml +24 -0
- sphinx_revealjs_ext_codeblock-0.1.0/.github/workflows/testing.yml +12 -0
- sphinx_revealjs_ext_codeblock-0.1.0/.gitignore +171 -0
- sphinx_revealjs_ext_codeblock-0.1.0/LICENSE +21 -0
- sphinx_revealjs_ext_codeblock-0.1.0/PKG-INFO +114 -0
- sphinx_revealjs_ext_codeblock-0.1.0/README.md +82 -0
- sphinx_revealjs_ext_codeblock-0.1.0/pyproject.toml +73 -0
- sphinx_revealjs_ext_codeblock-0.1.0/src/sphinx_revealjs_ext_codeblock/__about__.py +4 -0
- sphinx_revealjs_ext_codeblock-0.1.0/src/sphinx_revealjs_ext_codeblock/__init__.py +50 -0
- sphinx_revealjs_ext_codeblock-0.1.0/tests/__init__.py +3 -0
- sphinx_revealjs_ext_codeblock-0.1.0/tests/conftest.py +11 -0
- sphinx_revealjs_ext_codeblock-0.1.0/tests/roots/test-default/conf.py +11 -0
- sphinx_revealjs_ext_codeblock-0.1.0/tests/roots/test-default/index.rst +10 -0
- sphinx_revealjs_ext_codeblock-0.1.0/tests/roots/test-emphasize-lines/conf.py +11 -0
- sphinx_revealjs_ext_codeblock-0.1.0/tests/roots/test-emphasize-lines/index.rst +11 -0
- sphinx_revealjs_ext_codeblock-0.1.0/tests/roots/test-line-numbers/conf.py +11 -0
- sphinx_revealjs_ext_codeblock-0.1.0/tests/roots/test-line-numbers/index.rst +11 -0
- sphinx_revealjs_ext_codeblock-0.1.0/tests/test_sphinx_revealjs_ext_codeblock.py +45 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: Publish Python Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types:
|
|
6
|
+
- published
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
environment: pypi
|
|
12
|
+
permissions:
|
|
13
|
+
id-token: write
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: '3.12'
|
|
19
|
+
- uses: pypa/hatch@install
|
|
20
|
+
- name: Build package
|
|
21
|
+
run: |
|
|
22
|
+
hatch build
|
|
23
|
+
pipx run twine check dist/*
|
|
24
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
|
|
110
|
+
# pdm
|
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
112
|
+
#pdm.lock
|
|
113
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
114
|
+
# in version control.
|
|
115
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
116
|
+
.pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
#.idea/
|
|
169
|
+
|
|
170
|
+
# PyPI configuration file
|
|
171
|
+
.pypirc
|
|
@@ -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.
|
|
@@ -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
|
+
[](https://pypi.org/project/sphinx-revealjs-ext-codeblock)
|
|
36
|
+
[](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("Hello world!")
|
|
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("Hello world!")
|
|
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,82 @@
|
|
|
1
|
+
# sphinx-revealjs-ext-codeblock
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/sphinx-revealjs-ext-codeblock)
|
|
4
|
+
[](https://pypi.org/project/sphinx-revealjs-ext-codeblock)
|
|
5
|
+
|
|
6
|
+
Extend `code-block` directive for Sphinx `revealjs` builder.
|
|
7
|
+
|
|
8
|
+
-----
|
|
9
|
+
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
- [Installation](#installation)
|
|
13
|
+
- [Usage](#usage)
|
|
14
|
+
- [License](#license)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```console
|
|
19
|
+
pip install sphinx-revealjs-ext-codeblock
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
conf.py
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
extensions = [
|
|
28
|
+
"sphinx_revealjs",
|
|
29
|
+
"sphinx_revealjs_ext_codeblock",
|
|
30
|
+
]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Specify `revealjs_script_plugins` & `revealjs_css_files`.
|
|
34
|
+
|
|
35
|
+
* https://sphinx-revealjs.readthedocs.io/en/stable/configurations/#confval-revealjs_script_plugins
|
|
36
|
+
* https://sphinx-revealjs.readthedocs.io/en/stable/configurations/#confval-revealjs_css_files
|
|
37
|
+
|
|
38
|
+
### Line Numbers
|
|
39
|
+
|
|
40
|
+
```rst
|
|
41
|
+
.. code-block:: python
|
|
42
|
+
:linenos:
|
|
43
|
+
|
|
44
|
+
while True:
|
|
45
|
+
print("Hello world!")
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<pre>
|
|
50
|
+
<code class="python" data-line-numbers>
|
|
51
|
+
while True:
|
|
52
|
+
print("Hello world!")
|
|
53
|
+
</code>
|
|
54
|
+
</pre>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
See https://revealjs.com/code/#line-numbers-%26-highlights
|
|
58
|
+
|
|
59
|
+
### Highlights
|
|
60
|
+
|
|
61
|
+
```rst
|
|
62
|
+
.. code-block:: python
|
|
63
|
+
:emphasize-lines: 2
|
|
64
|
+
|
|
65
|
+
while True:
|
|
66
|
+
print("Hello world!")
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<pre>
|
|
71
|
+
<code class="python" data-line-numbers="2">
|
|
72
|
+
while True:
|
|
73
|
+
print("Hello world!")
|
|
74
|
+
</code>
|
|
75
|
+
</pre>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
See https://revealjs.com/code/#line-numbers-%26-highlights
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
`sphinx-revealjs-ext-codeblock` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sphinx-revealjs-ext-codeblock"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = 'Extend code-block directive for sphinx-revealjs builder'
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "ftnext", email = "takuyafjp+develop@gmail.com" },
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Framework :: Sphinx",
|
|
20
|
+
"Framework :: Sphinx :: Extension",
|
|
21
|
+
"Topic :: Documentation",
|
|
22
|
+
"Topic :: Documentation :: Sphinx",
|
|
23
|
+
"Topic :: Software Development :: Documentation",
|
|
24
|
+
"Topic :: Text Processing :: Markup :: HTML",
|
|
25
|
+
"Programming Language :: Python",
|
|
26
|
+
"Programming Language :: Python :: 3",
|
|
27
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
28
|
+
"Programming Language :: Python :: 3.9",
|
|
29
|
+
"Programming Language :: Python :: 3.10",
|
|
30
|
+
"Programming Language :: Python :: 3.11",
|
|
31
|
+
"Programming Language :: Python :: 3.12",
|
|
32
|
+
"Programming Language :: Python :: 3.13",
|
|
33
|
+
]
|
|
34
|
+
dependencies = ["sphinx-revealjs", "sphinxcontrib-extdevhelper-kasane"]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Documentation = "https://github.com/ftnext/sphinx-revealjs-ext-codeblock#readme"
|
|
38
|
+
Issues = "https://github.com/ftnext/sphinx-revealjs-ext-codeblock/issues"
|
|
39
|
+
Source = "https://github.com/ftnext/sphinx-revealjs-ext-codeblock"
|
|
40
|
+
|
|
41
|
+
[tool.hatch.version]
|
|
42
|
+
path = "src/sphinx_revealjs_ext_codeblock/__about__.py"
|
|
43
|
+
|
|
44
|
+
[tool.hatch.envs.hatch-test]
|
|
45
|
+
extra-dependencies = ["beautifulsoup4"]
|
|
46
|
+
[[tool.hatch.envs.hatch-test.matrix]]
|
|
47
|
+
python = ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
48
|
+
|
|
49
|
+
[tool.hatch.envs.types]
|
|
50
|
+
extra-dependencies = [
|
|
51
|
+
"mypy>=1.0.0",
|
|
52
|
+
]
|
|
53
|
+
[tool.hatch.envs.types.scripts]
|
|
54
|
+
check = "mypy --install-types --non-interactive {args:src/sphinx_revealjs_ext_codeblock tests}"
|
|
55
|
+
|
|
56
|
+
[tool.coverage.run]
|
|
57
|
+
source_pkgs = ["sphinx_revealjs_ext_codeblock", "tests"]
|
|
58
|
+
branch = true
|
|
59
|
+
parallel = true
|
|
60
|
+
omit = [
|
|
61
|
+
"src/sphinx_revealjs_ext_codeblock/__about__.py",
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
[tool.coverage.paths]
|
|
65
|
+
sphinx_revealjs_ext_codeblock = ["src/sphinx_revealjs_ext_codeblock", "*/sphinx-revealjs-ext-codeblock/src/sphinx_revealjs_ext_codeblock"]
|
|
66
|
+
tests = ["tests", "*/sphinx-revealjs-ext-codeblock/tests"]
|
|
67
|
+
|
|
68
|
+
[tool.coverage.report]
|
|
69
|
+
exclude_lines = [
|
|
70
|
+
"no cov",
|
|
71
|
+
"if __name__ == .__main__.:",
|
|
72
|
+
"if TYPE_CHECKING:",
|
|
73
|
+
]
|
|
@@ -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,11 @@
|
|
|
1
|
+
extensions = ["sphinx_revealjs", "sphinx_revealjs_ext_codeblock"]
|
|
2
|
+
|
|
3
|
+
revealjs_script_plugins = [
|
|
4
|
+
{
|
|
5
|
+
"name": "RevealHighlight",
|
|
6
|
+
"src": "revealjs/plugin/highlight/highlight.js",
|
|
7
|
+
},
|
|
8
|
+
]
|
|
9
|
+
revealjs_css_files = [
|
|
10
|
+
"revealjs/plugin/highlight/zenburn.css",
|
|
11
|
+
]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
extensions = ["sphinx_revealjs", "sphinx_revealjs_ext_codeblock"]
|
|
2
|
+
|
|
3
|
+
revealjs_script_plugins = [
|
|
4
|
+
{
|
|
5
|
+
"name": "RevealHighlight",
|
|
6
|
+
"src": "revealjs/plugin/highlight/highlight.js",
|
|
7
|
+
},
|
|
8
|
+
]
|
|
9
|
+
revealjs_css_files = [
|
|
10
|
+
"revealjs/plugin/highlight/zenburn.css",
|
|
11
|
+
]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
extensions = ["sphinx_revealjs", "sphinx_revealjs_ext_codeblock"]
|
|
2
|
+
|
|
3
|
+
revealjs_script_plugins = [
|
|
4
|
+
{
|
|
5
|
+
"name": "RevealHighlight",
|
|
6
|
+
"src": "revealjs/plugin/highlight/highlight.js",
|
|
7
|
+
},
|
|
8
|
+
]
|
|
9
|
+
revealjs_css_files = [
|
|
10
|
+
"revealjs/plugin/highlight/zenburn.css",
|
|
11
|
+
]
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from bs4 import BeautifulSoup
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@pytest.mark.sphinx("revealjs", testroot="default")
|
|
6
|
+
def test_normal_code_block(app):
|
|
7
|
+
app.build()
|
|
8
|
+
|
|
9
|
+
slide_contents = (app.outdir / "index.html").read_text()
|
|
10
|
+
soup = BeautifulSoup(slide_contents, "html.parser")
|
|
11
|
+
pre_tags = soup.find_all("pre")
|
|
12
|
+
assert len(pre_tags) == 1
|
|
13
|
+
pre_tag = pre_tags[0]
|
|
14
|
+
pre_attrs = pre_tag.attrs
|
|
15
|
+
assert pre_attrs["data-id"] == "code-block"
|
|
16
|
+
code_tag = pre_tag.code
|
|
17
|
+
code_attrs = code_tag.attrs
|
|
18
|
+
assert "data-trim" in code_attrs
|
|
19
|
+
assert "data-noescape" in code_attrs
|
|
20
|
+
assert "python" in code_attrs["class"]
|
|
21
|
+
assert "data-line-numbers" not in code_attrs
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@pytest.mark.sphinx("revealjs", testroot="line-numbers")
|
|
25
|
+
def test_code_block_linenos(app):
|
|
26
|
+
app.build()
|
|
27
|
+
|
|
28
|
+
slide_contents = (app.outdir / "index.html").read_text()
|
|
29
|
+
soup = BeautifulSoup(slide_contents, "html.parser")
|
|
30
|
+
pre_tags = soup.find_all("pre")
|
|
31
|
+
code_tag = pre_tags[0].code
|
|
32
|
+
code_attrs = code_tag.attrs
|
|
33
|
+
assert code_attrs["data-line-numbers"] == ""
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@pytest.mark.sphinx("revealjs", testroot="emphasize-lines")
|
|
37
|
+
def test_code_block_emphasize_lines(app):
|
|
38
|
+
app.build()
|
|
39
|
+
|
|
40
|
+
slide_contents = (app.outdir / "index.html").read_text()
|
|
41
|
+
soup = BeautifulSoup(slide_contents, "html.parser")
|
|
42
|
+
pre_tags = soup.find_all("pre")
|
|
43
|
+
code_tag = pre_tags[0].code
|
|
44
|
+
code_attrs = code_tag.attrs
|
|
45
|
+
assert code_attrs["data-line-numbers"] == "2"
|