Skip to main content

Python-Powered Markdown with executable code and dynamic content

Project description

PyExecMD: Python-Powered Markdown

PyExecMD is a revolutionary markup language that combines the simplicity of Markdown with the full power of Python. Write documents with executable code, dynamic content, and beautiful visualizations that update in real-time!

โœจ Features

  • ๐Ÿ Python-Based Syntax: Write markup using familiar Python function calls
  • ๐Ÿ”ด Live Preview: Real-time rendering with auto-refresh as you edit
  • ๐Ÿ“Š Rich Visualizations: Built-in support for matplotlib, pandas, and other data science libraries
  • ๐Ÿงฎ Dynamic Content: Execute Python code and display results inline
  • ๐Ÿ“ฑ Beautiful Output: Clean, responsive HTML with modern styling
  • โšก Fast Rendering: Efficient parsing and rendering engine
  • ๐Ÿ”„ Auto-Refresh: Changes reflect immediately in the live preview

๐Ÿš€ Quick Start

Installation

Option 1: Install from PyPI (Recommended)

pip install pyexecmd
Option 2: Install from source
  1. Clone the repository:

    git clone https://www.github.com/treeleaves30760/PyMD
    cd PyMD
    
  2. Install in development mode:

    pip install -e .
    

Usage

  1. Create a new PyExecMD document:

    pyexecmd create my_document.pymd
    
  2. Start live preview:

    pyexecmd serve my_document.pymd --port 8080
    

    Then open http://localhost:8080 in your browser

    Note for macOS users: Port 5000 is often used by AirPlay. Use --port 8000 or another port to avoid conflicts.

  3. Render to HTML:

    pyexecmd render my_document.pymd -o output.html
    

๐Ÿ“ PyExecMD Syntax

PyExecMD uses Python function calls to create content:

Headings

pymd.h1("Main Title")
pymd.h2("Section Title")
pymd.h3("Subsection Title")

Text

pymd.text("This is a paragraph of text.")
pymd.text("You can write **bold** and *italic* text too!")

Code Blocks

code_sample = '''
def hello_world():
    print("Hello, PyExecMD!")
'''
pymd.code(code_sample, "python")

Images and Plots

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10, 100)
y = np.sin(x)

plt.figure(figsize=(10, 6))
plt.plot(x, y)
plt.title("Sine Wave")

pymd.image(plt.gcf(), "Beautiful sine wave visualization")

Tables

import pandas as pd

df = pd.DataFrame({
    'Name': ['Alice', 'Bob', 'Charlie'],
    'Age': [25, 30, 35],
    'Score': [95, 87, 92]
})

pymd.table(df)

๐Ÿ“ Project Structure

PyMD/
โ”œโ”€โ”€ pymd/                   # Main package directory
โ”‚   โ”œโ”€โ”€ __init__.py        # Package initialization
โ”‚   โ”œโ”€โ”€ cli.py             # Command-line interface
โ”‚   โ”œโ”€โ”€ renderer.py        # Core rendering engine
โ”‚   โ””โ”€โ”€ server.py          # Live preview server
โ”œโ”€โ”€ example.pymd           # Example PyMD document
โ”œโ”€โ”€ pyproject.toml         # Package configuration
โ”œโ”€โ”€ MANIFEST.in            # Additional files to include
โ”œโ”€โ”€ LICENSE                # MIT License
โ”œโ”€โ”€ requirements.txt       # Python dependencies
โ””โ”€โ”€ README.md              # This file

๐Ÿ› ๏ธ API Reference

PyExecMD Class Methods

  • pymd.h1(text) - Create level 1 heading
  • pymd.h2(text) - Create level 2 heading
  • pymd.h3(text) - Create level 3 heading
  • pymd.text(content) - Create paragraph text
  • pymd.code(content, language) - Create code block
  • pymd.image(plot_obj, caption) - Render matplotlib plots
  • pymd.table(data) - Render pandas DataFrames or tables

CLI Commands

# Create new PyExecMD file from template
pyexecmd create <filename> [--force]

# Start live preview server
pyexecmd serve <file> [--port PORT] [--host HOST] [--debug]

# Render PyExecMD to HTML
pyexecmd render <input> [-o OUTPUT]

๐ŸŽฏ Use Cases

  • ๐Ÿ“Š Data Science Reports: Combine analysis, visualizations, and explanations
  • ๐Ÿ“š Interactive Documentation: Living documents that update with code changes
  • ๐ŸŽ“ Educational Materials: Tutorials with executable examples
  • ๐Ÿ“ˆ Dashboard Reports: Dynamic reports with real-time data
  • ๐Ÿ”ฌ Research Papers: Academic papers with reproducible results

๐ŸŒŸ Examples

Check out example.pymd for a comprehensive demonstration of PyExecMD features, including:

  • Beautiful data visualizations
  • Dynamic calculations
  • Interactive tables
  • Real-time updates

๐Ÿค Contributing

We welcome contributions! Please feel free to submit issues, feature requests, or pull requests.

๐Ÿ“„ License

This project is licensed under the MIT License.


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

pyexecmd-0.1.2.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

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

pyexecmd-0.1.2-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file pyexecmd-0.1.2.tar.gz.

File metadata

  • Download URL: pyexecmd-0.1.2.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for pyexecmd-0.1.2.tar.gz
Algorithm Hash digest
SHA256 378cd1aeb662600de29bfa49d4ae03332aa4f406bb9c9362be9518265e1a4eb5
MD5 70900438c543b179fc5ac43fe3b97aef
BLAKE2b-256 d84afa9118a07fcd782f550fc18d4de5c2a65a6cfb64938f209580753e416c10

See more details on using hashes here.

File details

Details for the file pyexecmd-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pyexecmd-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for pyexecmd-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5391783cf4ea34e75f9600f8f1745309fddfe6a8ef489249500d173f0e78ff01
MD5 7c2abc44573597c1cb792f0cc2a65830
BLAKE2b-256 95e6d975112652190f0ed0e00c2f0aba86c7a38bec18879a1633d5e6b3f11efc

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