Skip to main content

A lightweight dynamic module for automatic HTML reporting

Project description

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 numpy arrays and pandas DataFrames 📊
  • Static and interactive Matplotlib plots 📈

🚀 Installation

Install via pip:

pip install pergamos

For development:

pip install -e .[dev]

📌 Features

  • 🗙️ Markdown rendering with markdown and pygments
  • 🧬 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:

  1. Clone the repo:
    git clone https://github.com/manuelblancovalentin/pergamos.git
    cd pergamos
    
  2. Install dependencies:
    pip install -e .[dev]
    
  3. Run tests:
    pytest
    
  4. Submit a pull request 🚀

📍 License

This project is licensed under the MIT License.

📌 GitHub Repository: Pergamos

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pergamos-0.0.7.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pergamos-0.0.7-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file pergamos-0.0.7.tar.gz.

File metadata

  • Download URL: pergamos-0.0.7.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for pergamos-0.0.7.tar.gz
Algorithm Hash digest
SHA256 f69b728996f0a82045893bfca13537c3f65fd4d5ec414a25286389045fabdf69
MD5 f49676be1b52271a1fc9392206122b71
BLAKE2b-256 040065f8af374da001c3aba4e89321b6d3d133941837d57b723d62f2b27a6427

See more details on using hashes here.

File details

Details for the file pergamos-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: pergamos-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for pergamos-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 417b42d6d1021118313558baad2b6b72c869f64f53df2417d1ae7b310273d25f
MD5 dd54fd9a29b05079c792f495a64e823c
BLAKE2b-256 686293734793eb5ba1e9897105c850b8b7dd56e2810ece619534d0f1716122da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page