Pergamos: Dynamic HTML Reporting for Python
Pergamos is a lightweight Python module for automatically generating HTML reports with support for:
- Markdown rendering 🗙️
- LaTeX equations using MathJax 💢
- Syntax-highlighted code blocks 🎨
- Tables from
numpyarrays andpandasDataFrames 📊 - Static and interactive Matplotlib plots 📈
🚀 Installation
Install via pip:
pip install pergamos
For development:
pip install -e .[dev]
📌 Features
- 🗙️ Markdown rendering with
markdownandpygments - 🧬 LaTeX support via MathJax for equations
- 🎨 Syntax-highlighted code blocks (Python, JS, C++)
- 📊 Tables from lists, NumPy arrays, and Pandas DataFrames
- 📈 Plots using Matplotlib (both static & interactive)
- 📁 Collapsible & Tabbed Containers for better layout
🛠 Usage Examples
1️⃣ Creating an HTML Document
import pergamos as pg
doc = pg.Document("My Report")
doc.append(pg.Text("🚀 My Dynamic Report", tag='h1'))
doc.append(pg.Text("This is a dynamically generated report using Pergamos."))
doc.save("report.html")
🔹 Generates a simple HTML report with a title and text.
2️⃣ Adding Markdown Content
md_text = """
# Markdown Example
This is **bold**, *italic*, and `inline code`.
"""
doc.append(pg.Markdown(md_text))
🔹 Supports headings, bold, italics, and inline code.
3️⃣ Adding a Code Block with Syntax Highlighting
code = """
```python
def hello():
print("Hello, World!")
\```
"""
doc.append(pg.Markdown(code))
🔹 Renders Python syntax-highlighted inside a styled <pre><code> block.
4️⃣ Rendering LaTeX Equations
doc.append(pg.Latex(r"E = mc^2", inline=True))
doc.append(pg.Latex(r"\int_a^b x^2 \,dx", inline=False))
🔹 Supports inline and block LaTeX equations.
5️⃣ Displaying Tables
import numpy as np
import pandas as pd
array_data = np.random.randint(1, 100, (5, 5))
df = pd.DataFrame(array_data, columns=["A", "B", "C", "D", "E"])
doc.append(pg.Table(array_data)) # Numpy array
doc.append(pg.Table(df)) # Pandas DataFrame
🔹 Supports tables from lists, NumPy, and Pandas.
6️⃣ Adding a Static Plot
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1, 2, 3, 4], [10, 20, 25, 30])
doc.append(pg.Plot(fig))
🔹 Renders a static Matplotlib plot as an image.
7️⃣ Adding an Interactive Plot
doc.append(pg.InteractivePlot(fig))
🔹 Uses Mpld3 to create interactive zoomable plots.
🏠 Development & Contribution
To contribute:
- Clone the repo:
git clone https://github.com/manuelblancovalentin/pergamos.git cd pergamos
- Install dependencies:
pip install -e .[dev]
- Run tests:
pytest
- Submit a pull request 🚀
📍 License
This project is licensed under the MIT License.
📌 GitHub Repository: Pergamos
Release files for pergamos 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pergamos-0.0.8.tar.gz | 22.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pergamos-0.0.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.4 kB
Release files / pergamos-0.0.8.tar.gz
| Download URL | pergamos-0.0.8.tar.gz |
|---|---|
| Size | 22.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7981127eb8bab5d0a8105bc62b809837561449bbf472e264a3a319f272e0aa1c
|
|
BLAKE2b-256 checksum How to use checksums |
079bc0b42c2dba0856211ea8e1e0f6ab1df905ba81498c2c740ccb0e944647ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|
Release files / pergamos-0.0.8-py3-none-any.whl
| Download URL | pergamos-0.0.8-py3-none-any.whl |
|---|---|
| Size | 22.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c6365b34967a02d4cf880113b8be21bd986a984a4cb4bfe17e89ff3a3911ef9
|
|
BLAKE2b-256 checksum How to use checksums |
a119fa1df51bfeff85944d89f61be730dbceb7d1bb8038c7e53bf590aab32a4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|