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.1.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.1-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyexecmd-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 1ac65f0323483d858c32ddc1dd305995a5a76983ead523e46e5b166f22a04e4c
MD5 732ebb7837e7f42582bb680b276117c2
BLAKE2b-256 526084a32cdd7f76fab4be4252eea32f2068c357617129fb54f67490f9ec59f0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyexecmd-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cd01ab0c67e5d1d94ac77bb52d4a15d6e2780ed0fe54081d9265baf3086b0fc0
MD5 3eafad673154f0d3bd4c8aac3f86f918
BLAKE2b-256 b4841722c6d003035b14b767355fcfe98656973e420bcb800950a0007df3f616

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