html-to-pptx 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.
@@ -0,0 +1,31 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install -e ".[dev]"
28
+ python -m playwright install --with-deps chromium
29
+
30
+ - name: Run tests
31
+ run: pytest -v
@@ -0,0 +1,29 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ id-token: write
9
+
10
+ jobs:
11
+ publish:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.12"
21
+
22
+ - name: Install build tools
23
+ run: python -m pip install --upgrade pip build
24
+
25
+ - name: Build package
26
+ run: python -m build
27
+
28
+ - name: Publish to PyPI
29
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,218 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
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
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+ # Temporary file for partial code execution
204
+ tempCodeRunnerFile.py
205
+
206
+ # Ruff stuff:
207
+ .ruff_cache/
208
+
209
+ # PyPI configuration file
210
+ .pypirc
211
+
212
+ # Marimo
213
+ marimo/_static/
214
+ marimo/_lsp/
215
+ __marimo__/
216
+
217
+ # Streamlit
218
+ .streamlit/secrets.toml
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Design Arena
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,228 @@
1
+ Metadata-Version: 2.4
2
+ Name: html-to-pptx
3
+ Version: 0.1.0
4
+ Summary: Convert HTML slide decks to editable PowerPoint files using browser-based DOM measurement.
5
+ Project-URL: Homepage, https://github.com/Design-Arena/html-to-pptx
6
+ Project-URL: Repository, https://github.com/Design-Arena/html-to-pptx
7
+ Project-URL: Issues, https://github.com/Design-Arena/html-to-pptx/issues
8
+ Author: Design Arena
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: converter,html,powerpoint,pptx,presentation,slides
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Multimedia :: Graphics :: Presentation
21
+ Classifier: Topic :: Office/Business
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: lxml>=5.0.0
25
+ Requires-Dist: playwright>=1.40.0
26
+ Requires-Dist: python-pptx>=1.0.0
27
+ Provides-Extra: compare
28
+ Requires-Dist: pillow>=10.0.0; extra == 'compare'
29
+ Requires-Dist: pymupdf>=1.24.0; extra == 'compare'
30
+ Provides-Extra: dev
31
+ Requires-Dist: pillow>=10.0.0; extra == 'dev'
32
+ Requires-Dist: pymupdf>=1.24.0; extra == 'dev'
33
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
34
+ Requires-Dist: pytest>=8.0; extra == 'dev'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # html-to-pptx
38
+
39
+ Convert HTML slide decks into editable PowerPoint files.
40
+
41
+ Unlike screenshot-based approaches that produce flat images, `html-to-pptx` measures every DOM element in a headless browser and maps it to a native PPTX shape — text boxes you can edit, images you can resize, backgrounds you can restyle. The output is a real presentation, not a picture of one.
42
+
43
+ ## Install
44
+
45
+ ```bash
46
+ pip install html-to-pptx
47
+ python -m playwright install chromium
48
+ ```
49
+
50
+ ## Quick start
51
+
52
+ ### CLI
53
+
54
+ ```bash
55
+ html-to-pptx deck.html deck.pptx
56
+ ```
57
+
58
+ ### Python
59
+
60
+ ```python
61
+ import asyncio
62
+ from html_to_pptx import convert
63
+
64
+ asyncio.run(convert("deck.html", "deck.pptx"))
65
+ ```
66
+
67
+ ### Two-stage API
68
+
69
+ For more control, separate the measurement and rendering steps:
70
+
71
+ ```python
72
+ import asyncio
73
+ from html_to_pptx import extract_measurements, render_pptx
74
+
75
+ async def main():
76
+ # Stage 1: measure DOM elements in a headless browser
77
+ measurements = await extract_measurements("deck.html")
78
+
79
+ # Stage 2: render measurements to python-pptx shapes
80
+ prs = render_pptx(measurements)
81
+
82
+ # Modify the presentation before saving
83
+ prs.slides[0].shapes[0].text = "Custom title"
84
+ prs.save("deck.pptx")
85
+
86
+ asyncio.run(main())
87
+ ```
88
+
89
+ ## HTML format
90
+
91
+ Your HTML file should contain `<section class="slide">` elements at a 1920×1080 canvas:
92
+
93
+ ```html
94
+ <!DOCTYPE html>
95
+ <html>
96
+ <head>
97
+ <style>
98
+ * { margin: 0; padding: 0; box-sizing: border-box; }
99
+ body { background: #000; overflow: hidden; }
100
+ .slide {
101
+ width: 1920px;
102
+ height: 1080px;
103
+ display: none;
104
+ flex-direction: column;
105
+ justify-content: center;
106
+ align-items: center;
107
+ font-family: sans-serif;
108
+ }
109
+ .slide.active { display: flex; }
110
+ </style>
111
+ </head>
112
+ <body>
113
+
114
+ <section class="slide active" style="background-color: #1e293b;">
115
+ <h1 style="font-size: 64px; color: #f8fafc;">Hello World</h1>
116
+ </section>
117
+
118
+ <section class="slide" style="background-color: #ffffff;">
119
+ <p style="font-size: 24px; color: #334155;">Second slide</p>
120
+ </section>
121
+
122
+ </body>
123
+ </html>
124
+ ```
125
+
126
+ See [`examples/demo.html`](examples/demo.html) for a full five-slide deck.
127
+
128
+ ## What gets converted
129
+
130
+ | HTML feature | PPTX output |
131
+ |---|---|
132
+ | Text with fonts, colors, weight, style | Editable text boxes with matching font properties |
133
+ | Background colors | Solid fills (with alpha transparency) |
134
+ | Rounded corners (`border-radius`) | OOXML adjustment guides on rounded rectangles |
135
+ | Base64-embedded images (`data:image/...`) | Native picture shapes |
136
+ | Borders | Shape outlines with color and width |
137
+ | Left-border accent bars | Separate narrow rectangle shapes |
138
+ | `text-transform` (uppercase, etc.) | Transformed text content |
139
+ | Hyperlinks | Preserved on text runs |
140
+ | Ordered/unordered lists | Bullet/number prefixes with marker colors |
141
+ | Element opacity | OOXML alpha on fill colors |
142
+
143
+ ## How it works
144
+
145
+ ```
146
+ HTML file
147
+
148
+
149
+ ┌─────────────────────────┐
150
+ │ Headless Chromium │ ← Playwright loads the HTML at 1920×1080
151
+ │ (Playwright) │
152
+ │ │
153
+ │ For each .slide: │
154
+ │ • Show slide in isolation│
155
+ │ • Clear CSS transforms │
156
+ │ • Measure every visible │
157
+ │ element recursively: │
158
+ │ position, size, color,│
159
+ │ font, text, images │
160
+ └───────────┬─────────────┘
161
+
162
+
163
+ Measurement tree (JSON)
164
+
165
+
166
+ ┌─────────────────────────┐
167
+ │ python-pptx renderer │
168
+ │ │
169
+ │ For each element: │
170
+ │ • Text leaf → text box │
171
+ │ • Image → picture shape │
172
+ │ • Background → rectangle│
173
+ │ • Border → outline/shape│
174
+ │ │
175
+ │ Coordinates: │
176
+ │ CSS px → inches using │
177
+ │ 13.333/1920 ratio │
178
+ └───────────┬─────────────┘
179
+
180
+
181
+ Editable .pptx
182
+ ```
183
+
184
+ ## Visual comparison tool
185
+
186
+ Verify conversion quality with side-by-side comparisons:
187
+
188
+ ```bash
189
+ pip install html-to-pptx[compare]
190
+ html-to-pptx-compare deck.html -o results/
191
+ ```
192
+
193
+ This screenshots the original HTML, converts to PPTX, renders the PPTX back to images via LibreOffice, and creates side-by-side comparison PNGs. Requires [LibreOffice](https://www.libreoffice.org/) on PATH.
194
+
195
+ Output structure:
196
+ ```
197
+ results/deck/
198
+ ├── html_slide_0.png # ground truth (HTML screenshot)
199
+ ├── html_slide_1.png
200
+ ├── pptx_slide_0.png # converter output (PPTX rendered via LibreOffice)
201
+ ├── pptx_slide_1.png
202
+ ├── compare_slide_0.png # side-by-side comparison
203
+ ├── compare_slide_1.png
204
+ └── output.pptx # the generated file
205
+ ```
206
+
207
+ ## Limitations
208
+
209
+ - **External images** are not fetched — use base64 `data:` URIs for embedded images
210
+ - **CSS `background-image`** on containers is not converted — only `<img>` tags with base64 `src` become picture shapes
211
+ - **CSS gradients** are captured as the computed `backgroundColor` (solid), not as gradient fills
212
+ - **Animations and transitions** are not represented in PPTX
213
+ - **Font availability** — the PPTX references font names from the HTML; if those fonts aren't installed on the machine opening the file, PowerPoint will substitute
214
+ - **Complex CSS layouts** (grid, advanced flexbox) are measured as-rendered, but deeply nested layouts may lose some positioning precision
215
+
216
+ ## Development
217
+
218
+ ```bash
219
+ git clone https://github.com/Design-Arena/html-to-pptx.git
220
+ cd html-to-pptx
221
+ pip install -e ".[dev]"
222
+ python -m playwright install chromium
223
+ pytest -v
224
+ ```
225
+
226
+ ## License
227
+
228
+ MIT