narada 0.1.24__tar.gz → 0.1.26__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.
- {narada-0.1.24 → narada-0.1.26}/PKG-INFO +1 -1
- {narada-0.1.24 → narada-0.1.26}/pyproject.toml +1 -1
- narada-0.1.26/src/narada/render_html.py +21 -0
- narada-0.1.24/src/narada/render_html.py +0 -17
- {narada-0.1.24 → narada-0.1.26}/.gitignore +0 -0
- {narada-0.1.24 → narada-0.1.26}/README.md +0 -0
- {narada-0.1.24 → narada-0.1.26}/src/narada/__init__.py +0 -0
- {narada-0.1.24 → narada-0.1.26}/src/narada/client.py +0 -0
- {narada-0.1.24 → narada-0.1.26}/src/narada/config.py +0 -0
- {narada-0.1.24 → narada-0.1.26}/src/narada/py.typed +0 -0
- {narada-0.1.24 → narada-0.1.26}/src/narada/utils.py +0 -0
- {narada-0.1.24 → narada-0.1.26}/src/narada/window.py +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import webbrowser
|
|
2
|
+
from tempfile import NamedTemporaryFile
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def render_html(html: str) -> None:
|
|
6
|
+
"""
|
|
7
|
+
Renders HTML content by opening it in the default browser.
|
|
8
|
+
|
|
9
|
+
Args:
|
|
10
|
+
html: The HTML content to render.
|
|
11
|
+
"""
|
|
12
|
+
with NamedTemporaryFile(
|
|
13
|
+
mode="w+t",
|
|
14
|
+
encoding="utf-8",
|
|
15
|
+
suffix=".html",
|
|
16
|
+
delete=False,
|
|
17
|
+
) as temp:
|
|
18
|
+
temp.write(html)
|
|
19
|
+
path = temp.name
|
|
20
|
+
|
|
21
|
+
webbrowser.open_new_tab(f"file://{path}")
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import base64
|
|
2
|
-
import webbrowser
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def render_html(html: str) -> None:
|
|
6
|
-
"""
|
|
7
|
-
Renders HTML content by opening it in the default browser.
|
|
8
|
-
|
|
9
|
-
Args:
|
|
10
|
-
html: The HTML content to render.
|
|
11
|
-
"""
|
|
12
|
-
# Encode HTML to base64 for data URL
|
|
13
|
-
html_bytes = html.encode("utf-8")
|
|
14
|
-
html_base64 = base64.b64encode(html_bytes).decode("utf-8")
|
|
15
|
-
# Create data URL
|
|
16
|
-
data_url = f"data:text/html;base64,{html_base64}"
|
|
17
|
-
webbrowser.open_new_tab(data_url)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|