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 .
    

Quick Test

pyexecmd serve example.pymd --port 8000

Basic Usage

  1. Create a new PyExecMD document:

    pyexecmd create my_document.pymd
    
  2. Start live preview:

    pyexecmd serve my_document.pymd --port 8000
    

    Then open http://localhost:8000 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.0.tar.gz (18.8 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.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyexecmd-0.1.0.tar.gz
  • Upload date:
  • Size: 18.8 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.0.tar.gz
Algorithm Hash digest
SHA256 d415d52b1690317c98aad43177df77fbdd9a8e8b1b19ae28d35a835876265731
MD5 9e4c032a3af1a2689dd3e4e7ec815604
BLAKE2b-256 9d93df6418d62682be4ee770f9f632f5ac48be66953285fd296f8ddda32361cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyexecmd-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.3 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e65c1898b1c00ba9e57f92b2caa448fbda342a75310ebef61568b17a5f8833eb
MD5 a3343c52ec8dd6456368a8a187293a4d
BLAKE2b-256 f389435414a95a8ba9ef4bbb3a063707f3326243e0aa860cc590316686c79230

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