swarmauri_tool_jupyterexporthtml 0.8.0.dev3__tar.gz → 0.8.0.dev22__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.
- swarmauri_tool_jupyterexporthtml-0.8.0.dev22/PKG-INFO +104 -0
- swarmauri_tool_jupyterexporthtml-0.8.0.dev22/README.md +78 -0
- {swarmauri_tool_jupyterexporthtml-0.8.0.dev3 → swarmauri_tool_jupyterexporthtml-0.8.0.dev22}/pyproject.toml +22 -1
- swarmauri_tool_jupyterexporthtml-0.8.0.dev3/PKG-INFO +0 -138
- swarmauri_tool_jupyterexporthtml-0.8.0.dev3/README.md +0 -118
- {swarmauri_tool_jupyterexporthtml-0.8.0.dev3 → swarmauri_tool_jupyterexporthtml-0.8.0.dev22}/LICENSE +0 -0
- {swarmauri_tool_jupyterexporthtml-0.8.0.dev3 → swarmauri_tool_jupyterexporthtml-0.8.0.dev22}/swarmauri_tool_jupyterexporthtml/JupyterExportHtmlTool.py +0 -0
- {swarmauri_tool_jupyterexporthtml-0.8.0.dev3 → swarmauri_tool_jupyterexporthtml-0.8.0.dev22}/swarmauri_tool_jupyterexporthtml/__init__.py +0 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: swarmauri_tool_jupyterexporthtml
|
|
3
|
+
Version: 0.8.0.dev22
|
|
4
|
+
Summary: A tool that exports a Jupyter Notebook to HTML format using nbconvert’s HTMLExporter, enabling web-based presentation of notebooks.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: swarmauri,tool,jupyterexporthtml,exports,jupyter,notebook,html,format,nbconvert,htmlexporter,enabling,web,based,presentation,notebooks
|
|
8
|
+
Author: Jacob Stewart
|
|
9
|
+
Author-email: jacob@swarmauri.com
|
|
10
|
+
Requires-Python: >=3.10,<3.13
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Natural Language :: English
|
|
17
|
+
Classifier: Development Status :: 3 - Alpha
|
|
18
|
+
Classifier: Intended Audience :: Developers
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
20
|
+
Requires-Dist: nbconvert (>=7.16.6)
|
|
21
|
+
Requires-Dist: swarmauri_base
|
|
22
|
+
Requires-Dist: swarmauri_core
|
|
23
|
+
Requires-Dist: swarmauri_standard
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+
|
|
28
|
+
<p align="center">
|
|
29
|
+
<a href="https://pypi.org/project/swarmauri_tool_jupyterexporthtml/">
|
|
30
|
+
<img src="https://img.shields.io/pypi/dm/swarmauri_tool_jupyterexporthtml" alt="PyPI - Downloads"/></a>
|
|
31
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterexporthtml/">
|
|
32
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterexporthtml.svg"/></a>
|
|
33
|
+
<a href="https://pypi.org/project/swarmauri_tool_jupyterexporthtml/">
|
|
34
|
+
<img src="https://img.shields.io/pypi/pyversions/swarmauri_tool_jupyterexporthtml" alt="PyPI - Python Version"/></a>
|
|
35
|
+
<a href="https://pypi.org/project/swarmauri_tool_jupyterexporthtml/">
|
|
36
|
+
<img src="https://img.shields.io/pypi/l/swarmauri_tool_jupyterexporthtml" alt="PyPI - License"/></a>
|
|
37
|
+
<a href="https://pypi.org/project/swarmauri_tool_jupyterexporthtml/">
|
|
38
|
+
<img src="https://img.shields.io/pypi/v/swarmauri_tool_jupyterexporthtml?label=swarmauri_tool_jupyterexporthtml&color=green" alt="PyPI - swarmauri_tool_jupyterexporthtml"/></a>
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
# Swarmauri Tool Jupyter Export HTML
|
|
44
|
+
|
|
45
|
+
Converts a Jupyter notebook (passed in as JSON) to HTML using nbconvert’s `HTMLExporter` with optional custom templates, CSS, and JavaScript.
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- Accepts notebook data as a JSON string (e.g., from `json.dumps(nbformat.read(...))`).
|
|
50
|
+
- Supports optional template, inline CSS, and inline JS injection.
|
|
51
|
+
- Returns a dict containing `exported_html` or `error` when conversion fails.
|
|
52
|
+
|
|
53
|
+
## Prerequisites
|
|
54
|
+
|
|
55
|
+
- Python 3.10 or newer.
|
|
56
|
+
- `nbconvert`, `nbformat`, and Swarmauri base/core packages (installed automatically).
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# pip
|
|
62
|
+
pip install swarmauri_tool_jupyterexporthtml
|
|
63
|
+
|
|
64
|
+
# poetry
|
|
65
|
+
poetry add swarmauri_tool_jupyterexporthtml
|
|
66
|
+
|
|
67
|
+
# uv (pyproject-based projects)
|
|
68
|
+
uv add swarmauri_tool_jupyterexporthtml
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Quickstart
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
import json
|
|
75
|
+
import nbformat
|
|
76
|
+
from swarmauri_tool_jupyterexporthtml import JupyterExportHTMLTool
|
|
77
|
+
|
|
78
|
+
notebook = nbformat.read("notebooks/example.ipynb", as_version=4)
|
|
79
|
+
notebook_json = json.dumps(notebook)
|
|
80
|
+
|
|
81
|
+
exporter = JupyterExportHTMLTool()
|
|
82
|
+
response = exporter(
|
|
83
|
+
notebook_json=notebook_json,
|
|
84
|
+
template_file=None,
|
|
85
|
+
extra_css="body { font-family: Arial; }",
|
|
86
|
+
extra_js="console.log('Export complete');",
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
if "exported_html" in response:
|
|
90
|
+
Path("notebooks/example.html").write_text(response["exported_html"], encoding="utf-8")
|
|
91
|
+
else:
|
|
92
|
+
print("Error:", response["error"])
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Tips
|
|
96
|
+
|
|
97
|
+
- nbconvert templates let you customize the layout; pass a `.tpl` file to `template_file`.
|
|
98
|
+
- Keep `extra_css`/`extra_js` lightweight to avoid bloating the HTML output.
|
|
99
|
+
- Combine with notebook execution tools (execute → export → publish) for end-to-end pipelines.
|
|
100
|
+
|
|
101
|
+
## Want to help?
|
|
102
|
+
|
|
103
|
+
If you want to contribute to swarmauri-sdk, read up on our [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/contributing.md) that will help you get started.
|
|
104
|
+
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://pypi.org/project/swarmauri_tool_jupyterexporthtml/">
|
|
5
|
+
<img src="https://img.shields.io/pypi/dm/swarmauri_tool_jupyterexporthtml" alt="PyPI - Downloads"/></a>
|
|
6
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterexporthtml/">
|
|
7
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterexporthtml.svg"/></a>
|
|
8
|
+
<a href="https://pypi.org/project/swarmauri_tool_jupyterexporthtml/">
|
|
9
|
+
<img src="https://img.shields.io/pypi/pyversions/swarmauri_tool_jupyterexporthtml" alt="PyPI - Python Version"/></a>
|
|
10
|
+
<a href="https://pypi.org/project/swarmauri_tool_jupyterexporthtml/">
|
|
11
|
+
<img src="https://img.shields.io/pypi/l/swarmauri_tool_jupyterexporthtml" alt="PyPI - License"/></a>
|
|
12
|
+
<a href="https://pypi.org/project/swarmauri_tool_jupyterexporthtml/">
|
|
13
|
+
<img src="https://img.shields.io/pypi/v/swarmauri_tool_jupyterexporthtml?label=swarmauri_tool_jupyterexporthtml&color=green" alt="PyPI - swarmauri_tool_jupyterexporthtml"/></a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Swarmauri Tool Jupyter Export HTML
|
|
19
|
+
|
|
20
|
+
Converts a Jupyter notebook (passed in as JSON) to HTML using nbconvert’s `HTMLExporter` with optional custom templates, CSS, and JavaScript.
|
|
21
|
+
|
|
22
|
+
## Features
|
|
23
|
+
|
|
24
|
+
- Accepts notebook data as a JSON string (e.g., from `json.dumps(nbformat.read(...))`).
|
|
25
|
+
- Supports optional template, inline CSS, and inline JS injection.
|
|
26
|
+
- Returns a dict containing `exported_html` or `error` when conversion fails.
|
|
27
|
+
|
|
28
|
+
## Prerequisites
|
|
29
|
+
|
|
30
|
+
- Python 3.10 or newer.
|
|
31
|
+
- `nbconvert`, `nbformat`, and Swarmauri base/core packages (installed automatically).
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# pip
|
|
37
|
+
pip install swarmauri_tool_jupyterexporthtml
|
|
38
|
+
|
|
39
|
+
# poetry
|
|
40
|
+
poetry add swarmauri_tool_jupyterexporthtml
|
|
41
|
+
|
|
42
|
+
# uv (pyproject-based projects)
|
|
43
|
+
uv add swarmauri_tool_jupyterexporthtml
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quickstart
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import json
|
|
50
|
+
import nbformat
|
|
51
|
+
from swarmauri_tool_jupyterexporthtml import JupyterExportHTMLTool
|
|
52
|
+
|
|
53
|
+
notebook = nbformat.read("notebooks/example.ipynb", as_version=4)
|
|
54
|
+
notebook_json = json.dumps(notebook)
|
|
55
|
+
|
|
56
|
+
exporter = JupyterExportHTMLTool()
|
|
57
|
+
response = exporter(
|
|
58
|
+
notebook_json=notebook_json,
|
|
59
|
+
template_file=None,
|
|
60
|
+
extra_css="body { font-family: Arial; }",
|
|
61
|
+
extra_js="console.log('Export complete');",
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
if "exported_html" in response:
|
|
65
|
+
Path("notebooks/example.html").write_text(response["exported_html"], encoding="utf-8")
|
|
66
|
+
else:
|
|
67
|
+
print("Error:", response["error"])
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Tips
|
|
71
|
+
|
|
72
|
+
- nbconvert templates let you customize the layout; pass a `.tpl` file to `template_file`.
|
|
73
|
+
- Keep `extra_css`/`extra_js` lightweight to avoid bloating the HTML output.
|
|
74
|
+
- Combine with notebook execution tools (execute → export → publish) for end-to-end pipelines.
|
|
75
|
+
|
|
76
|
+
## Want to help?
|
|
77
|
+
|
|
78
|
+
If you want to contribute to swarmauri-sdk, read up on our [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/contributing.md) that will help you get started.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "swarmauri_tool_jupyterexporthtml"
|
|
3
|
-
version = "0.8.0.
|
|
3
|
+
version = "0.8.0.dev22"
|
|
4
4
|
description = "A tool that exports a Jupyter Notebook to HTML format using nbconvert’s HTMLExporter, enabling web-based presentation of notebooks."
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
readme = "README.md"
|
|
@@ -12,6 +12,10 @@ classifiers = [
|
|
|
12
12
|
"Programming Language :: Python :: 3.11",
|
|
13
13
|
"Programming Language :: Python :: 3.12",
|
|
14
14
|
"Programming Language :: Python :: 3.13",
|
|
15
|
+
"Natural Language :: English",
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Topic :: Software Development :: Libraries :: Application Frameworks",
|
|
15
19
|
]
|
|
16
20
|
authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
|
|
17
21
|
dependencies = [
|
|
@@ -20,6 +24,23 @@ dependencies = [
|
|
|
20
24
|
"swarmauri_base",
|
|
21
25
|
"swarmauri_standard",
|
|
22
26
|
]
|
|
27
|
+
keywords = [
|
|
28
|
+
"swarmauri",
|
|
29
|
+
"tool",
|
|
30
|
+
"jupyterexporthtml",
|
|
31
|
+
"exports",
|
|
32
|
+
"jupyter",
|
|
33
|
+
"notebook",
|
|
34
|
+
"html",
|
|
35
|
+
"format",
|
|
36
|
+
"nbconvert",
|
|
37
|
+
"htmlexporter",
|
|
38
|
+
"enabling",
|
|
39
|
+
"web",
|
|
40
|
+
"based",
|
|
41
|
+
"presentation",
|
|
42
|
+
"notebooks",
|
|
43
|
+
]
|
|
23
44
|
|
|
24
45
|
[tool.uv.sources]
|
|
25
46
|
swarmauri_core = { workspace = true }
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: swarmauri_tool_jupyterexporthtml
|
|
3
|
-
Version: 0.8.0.dev3
|
|
4
|
-
Summary: A tool that exports a Jupyter Notebook to HTML format using nbconvert’s HTMLExporter, enabling web-based presentation of notebooks.
|
|
5
|
-
License: Apache-2.0
|
|
6
|
-
Author: Jacob Stewart
|
|
7
|
-
Author-email: jacob@swarmauri.com
|
|
8
|
-
Requires-Python: >=3.10,<3.13
|
|
9
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
-
Requires-Dist: nbconvert (>=7.16.6)
|
|
15
|
-
Requires-Dist: swarmauri_base
|
|
16
|
-
Requires-Dist: swarmauri_core
|
|
17
|
-
Requires-Dist: swarmauri_standard
|
|
18
|
-
Description-Content-Type: text/markdown
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-

|
|
22
|
-
|
|
23
|
-
<p align="center">
|
|
24
|
-
<a href="https://pypi.org/project/swarmauri_tool_jupyterexporthtml/">
|
|
25
|
-
<img src="https://img.shields.io/pypi/dm/swarmauri_tool_jupyterexporthtml" alt="PyPI - Downloads"/></a>
|
|
26
|
-
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterexporthtml/">
|
|
27
|
-
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterexporthtml.svg"/></a>
|
|
28
|
-
<a href="https://pypi.org/project/swarmauri_tool_jupyterexporthtml/">
|
|
29
|
-
<img src="https://img.shields.io/pypi/pyversions/swarmauri_tool_jupyterexporthtml" alt="PyPI - Python Version"/></a>
|
|
30
|
-
<a href="https://pypi.org/project/swarmauri_tool_jupyterexporthtml/">
|
|
31
|
-
<img src="https://img.shields.io/pypi/l/swarmauri_tool_jupyterexporthtml" alt="PyPI - License"/></a>
|
|
32
|
-
<a href="https://pypi.org/project/swarmauri_tool_jupyterexporthtml/">
|
|
33
|
-
<img src="https://img.shields.io/pypi/v/swarmauri_tool_jupyterexporthtml?label=swarmauri_tool_jupyterexporthtml&color=green" alt="PyPI - swarmauri_tool_jupyterexporthtml"/></a>
|
|
34
|
-
</p>
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
# Swarmauri Tool Jupyter Export Html
|
|
39
|
-
|
|
40
|
-
The purpose of this package is to provide a flexible tool for converting Jupyter Notebook content into HTML format using nbconvert’s HTMLExporter. This enables easy presentation, sharing, or embedding of Jupyter Notebook content into various workflows or web applications.
|
|
41
|
-
|
|
42
|
-
## Installation
|
|
43
|
-
|
|
44
|
-
Since this package is published for Python 3.10 to 3.13, you will need a recent version of Python. To install:
|
|
45
|
-
|
|
46
|
-
1. Ensure you have the required dependencies, including nbconvert, installed.
|
|
47
|
-
2. Run the following command in your preferred Python environment to install from PyPI:
|
|
48
|
-
|
|
49
|
-
pip install swarmauri_tool_jupyterexporthtml
|
|
50
|
-
|
|
51
|
-
3. You’re ready to begin using the JupyterExportHTMLTool in your projects.
|
|
52
|
-
|
|
53
|
-
### Dependencies
|
|
54
|
-
• nbconvert (for converting Notebook content into HTML)
|
|
55
|
-
• swarmauri_core, swarmauri_base (for Swarmauri framework integration)
|
|
56
|
-
|
|
57
|
-
These are automatically installed when you install this package.
|
|
58
|
-
|
|
59
|
-
## Usage
|
|
60
|
-
|
|
61
|
-
Below is a short guide showing how to import and use the tool in your own Python code. The JupyterExportHTMLTool accepts a JSON-formatted string representing the notebook data, plus optional template, CSS, and JavaScript parameters.
|
|
62
|
-
|
|
63
|
-
Example usage:
|
|
64
|
-
|
|
65
|
-
--------------------------------------------------------------------------------
|
|
66
|
-
|
|
67
|
-
from swarmauri_tool_jupyterexporthtml import JupyterExportHTMLTool
|
|
68
|
-
|
|
69
|
-
# Example Notebook JSON (this would typically be read from a file or other source)
|
|
70
|
-
notebook_json_str = '''
|
|
71
|
-
{
|
|
72
|
-
"cells": [
|
|
73
|
-
{
|
|
74
|
-
"cell_type": "markdown",
|
|
75
|
-
"metadata": {},
|
|
76
|
-
"source": [
|
|
77
|
-
"# Hello World\\n",
|
|
78
|
-
"This is a sample notebook cell."
|
|
79
|
-
]
|
|
80
|
-
}
|
|
81
|
-
],
|
|
82
|
-
"metadata": {},
|
|
83
|
-
"nbformat": 4,
|
|
84
|
-
"nbformat_minor": 5
|
|
85
|
-
}
|
|
86
|
-
'''
|
|
87
|
-
|
|
88
|
-
# Create an instance of the exporter
|
|
89
|
-
exporter = JupyterExportHTMLTool()
|
|
90
|
-
|
|
91
|
-
# Call the exporter with optional parameters
|
|
92
|
-
result = exporter(
|
|
93
|
-
notebook_json=notebook_json_str,
|
|
94
|
-
template_file=None, # or specify a path to a custom template
|
|
95
|
-
extra_css="body { font-family: Arial, sans-serif; }",
|
|
96
|
-
extra_js="console.log('HTML Export Ready!');"
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
# Check for success
|
|
100
|
-
if "exported_html" in result:
|
|
101
|
-
# Save or process the HTML output
|
|
102
|
-
html_content = result["exported_html"]
|
|
103
|
-
print("Notebook conversion to HTML was successful. Length of output:", len(html_content))
|
|
104
|
-
else:
|
|
105
|
-
# Handle any error messages
|
|
106
|
-
print("Error during export:", result.get("error"))
|
|
107
|
-
|
|
108
|
-
--------------------------------------------------------------------------------
|
|
109
|
-
|
|
110
|
-
### Method Summary
|
|
111
|
-
|
|
112
|
-
The JupyterExportHTMLTool class implements a callable interface, expecting parameters such as:
|
|
113
|
-
• notebook_json (required): A string containing Jupyter Notebook data in valid JSON format.
|
|
114
|
-
• template_file (optional): Path to an nbconvert-compatible template.
|
|
115
|
-
• extra_css (optional): Inline styles you wish to embed into the resulting HTML.
|
|
116
|
-
• extra_js (optional): Inline JavaScript you wish to embed before the closing body tag.
|
|
117
|
-
|
|
118
|
-
It returns a dictionary containing either “exported_html” with the final HTML string or “error” with a message describing any failure.
|
|
119
|
-
|
|
120
|
-
## Advanced Usage
|
|
121
|
-
|
|
122
|
-
Use a custom template to further influence how the notebook is rendered. For instance, with an nbconvert template:
|
|
123
|
-
|
|
124
|
-
result = exporter(
|
|
125
|
-
notebook_json=notebook_json_str,
|
|
126
|
-
template_file="custom_template.tpl",
|
|
127
|
-
extra_css="header { color: blue; }",
|
|
128
|
-
extra_js="alert('Notebook Conversion Complete!');"
|
|
129
|
-
)
|
|
130
|
-
|
|
131
|
-
The extra_css parameter is injected inside a <style> tag, and extra_js is injected in a <script> tag at the end of the file. This allows you to easily tailor styling or behavior without manually editing the exported HTML.
|
|
132
|
-
|
|
133
|
-
--------------------------------------------------------------------------------
|
|
134
|
-
|
|
135
|
-
For further details, please refer to the code docstrings in JupyterExportHTMLTool.py. This README should be enough to get you started with installation, configuration, and usage in your own environment.
|
|
136
|
-
|
|
137
|
-
Happy exporting!
|
|
138
|
-
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-

|
|
3
|
-
|
|
4
|
-
<p align="center">
|
|
5
|
-
<a href="https://pypi.org/project/swarmauri_tool_jupyterexporthtml/">
|
|
6
|
-
<img src="https://img.shields.io/pypi/dm/swarmauri_tool_jupyterexporthtml" alt="PyPI - Downloads"/></a>
|
|
7
|
-
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterexporthtml/">
|
|
8
|
-
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_jupyterexporthtml.svg"/></a>
|
|
9
|
-
<a href="https://pypi.org/project/swarmauri_tool_jupyterexporthtml/">
|
|
10
|
-
<img src="https://img.shields.io/pypi/pyversions/swarmauri_tool_jupyterexporthtml" alt="PyPI - Python Version"/></a>
|
|
11
|
-
<a href="https://pypi.org/project/swarmauri_tool_jupyterexporthtml/">
|
|
12
|
-
<img src="https://img.shields.io/pypi/l/swarmauri_tool_jupyterexporthtml" alt="PyPI - License"/></a>
|
|
13
|
-
<a href="https://pypi.org/project/swarmauri_tool_jupyterexporthtml/">
|
|
14
|
-
<img src="https://img.shields.io/pypi/v/swarmauri_tool_jupyterexporthtml?label=swarmauri_tool_jupyterexporthtml&color=green" alt="PyPI - swarmauri_tool_jupyterexporthtml"/></a>
|
|
15
|
-
</p>
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
# Swarmauri Tool Jupyter Export Html
|
|
20
|
-
|
|
21
|
-
The purpose of this package is to provide a flexible tool for converting Jupyter Notebook content into HTML format using nbconvert’s HTMLExporter. This enables easy presentation, sharing, or embedding of Jupyter Notebook content into various workflows or web applications.
|
|
22
|
-
|
|
23
|
-
## Installation
|
|
24
|
-
|
|
25
|
-
Since this package is published for Python 3.10 to 3.13, you will need a recent version of Python. To install:
|
|
26
|
-
|
|
27
|
-
1. Ensure you have the required dependencies, including nbconvert, installed.
|
|
28
|
-
2. Run the following command in your preferred Python environment to install from PyPI:
|
|
29
|
-
|
|
30
|
-
pip install swarmauri_tool_jupyterexporthtml
|
|
31
|
-
|
|
32
|
-
3. You’re ready to begin using the JupyterExportHTMLTool in your projects.
|
|
33
|
-
|
|
34
|
-
### Dependencies
|
|
35
|
-
• nbconvert (for converting Notebook content into HTML)
|
|
36
|
-
• swarmauri_core, swarmauri_base (for Swarmauri framework integration)
|
|
37
|
-
|
|
38
|
-
These are automatically installed when you install this package.
|
|
39
|
-
|
|
40
|
-
## Usage
|
|
41
|
-
|
|
42
|
-
Below is a short guide showing how to import and use the tool in your own Python code. The JupyterExportHTMLTool accepts a JSON-formatted string representing the notebook data, plus optional template, CSS, and JavaScript parameters.
|
|
43
|
-
|
|
44
|
-
Example usage:
|
|
45
|
-
|
|
46
|
-
--------------------------------------------------------------------------------
|
|
47
|
-
|
|
48
|
-
from swarmauri_tool_jupyterexporthtml import JupyterExportHTMLTool
|
|
49
|
-
|
|
50
|
-
# Example Notebook JSON (this would typically be read from a file or other source)
|
|
51
|
-
notebook_json_str = '''
|
|
52
|
-
{
|
|
53
|
-
"cells": [
|
|
54
|
-
{
|
|
55
|
-
"cell_type": "markdown",
|
|
56
|
-
"metadata": {},
|
|
57
|
-
"source": [
|
|
58
|
-
"# Hello World\\n",
|
|
59
|
-
"This is a sample notebook cell."
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
],
|
|
63
|
-
"metadata": {},
|
|
64
|
-
"nbformat": 4,
|
|
65
|
-
"nbformat_minor": 5
|
|
66
|
-
}
|
|
67
|
-
'''
|
|
68
|
-
|
|
69
|
-
# Create an instance of the exporter
|
|
70
|
-
exporter = JupyterExportHTMLTool()
|
|
71
|
-
|
|
72
|
-
# Call the exporter with optional parameters
|
|
73
|
-
result = exporter(
|
|
74
|
-
notebook_json=notebook_json_str,
|
|
75
|
-
template_file=None, # or specify a path to a custom template
|
|
76
|
-
extra_css="body { font-family: Arial, sans-serif; }",
|
|
77
|
-
extra_js="console.log('HTML Export Ready!');"
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
# Check for success
|
|
81
|
-
if "exported_html" in result:
|
|
82
|
-
# Save or process the HTML output
|
|
83
|
-
html_content = result["exported_html"]
|
|
84
|
-
print("Notebook conversion to HTML was successful. Length of output:", len(html_content))
|
|
85
|
-
else:
|
|
86
|
-
# Handle any error messages
|
|
87
|
-
print("Error during export:", result.get("error"))
|
|
88
|
-
|
|
89
|
-
--------------------------------------------------------------------------------
|
|
90
|
-
|
|
91
|
-
### Method Summary
|
|
92
|
-
|
|
93
|
-
The JupyterExportHTMLTool class implements a callable interface, expecting parameters such as:
|
|
94
|
-
• notebook_json (required): A string containing Jupyter Notebook data in valid JSON format.
|
|
95
|
-
• template_file (optional): Path to an nbconvert-compatible template.
|
|
96
|
-
• extra_css (optional): Inline styles you wish to embed into the resulting HTML.
|
|
97
|
-
• extra_js (optional): Inline JavaScript you wish to embed before the closing body tag.
|
|
98
|
-
|
|
99
|
-
It returns a dictionary containing either “exported_html” with the final HTML string or “error” with a message describing any failure.
|
|
100
|
-
|
|
101
|
-
## Advanced Usage
|
|
102
|
-
|
|
103
|
-
Use a custom template to further influence how the notebook is rendered. For instance, with an nbconvert template:
|
|
104
|
-
|
|
105
|
-
result = exporter(
|
|
106
|
-
notebook_json=notebook_json_str,
|
|
107
|
-
template_file="custom_template.tpl",
|
|
108
|
-
extra_css="header { color: blue; }",
|
|
109
|
-
extra_js="alert('Notebook Conversion Complete!');"
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
The extra_css parameter is injected inside a <style> tag, and extra_js is injected in a <script> tag at the end of the file. This allows you to easily tailor styling or behavior without manually editing the exported HTML.
|
|
113
|
-
|
|
114
|
-
--------------------------------------------------------------------------------
|
|
115
|
-
|
|
116
|
-
For further details, please refer to the code docstrings in JupyterExportHTMLTool.py. This README should be enough to get you started with installation, configuration, and usage in your own environment.
|
|
117
|
-
|
|
118
|
-
Happy exporting!
|
{swarmauri_tool_jupyterexporthtml-0.8.0.dev3 → swarmauri_tool_jupyterexporthtml-0.8.0.dev22}/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|