Expand description
§MDZ - Markdown Zip Library
A Rust library for creating and working with MDZ (Markdown Zip) files. MDZ is a ZIP-based archive format that bundles Markdown documents with their embedded assets (images, videos, audio, and other files) into a single, portable file.
§Features
- Automatic Asset Processing: Download network images and copy local files
- Smart Link Resolution: Convert absolute paths to relative paths for maximum compatibility
- UUID-based Naming: Use UUIDs for downloaded assets to avoid conflicts
- Backward Compatibility: Handle legacy MDZ files seamlessly
- Rich Metadata: Complete manifest with document and asset information
§Quick Start
use mdz_rs::{pack, unpack};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Pack a markdown file with assets
pack("document.md", "document.mdz").await?;
// Unpack MDZ file to extract content and assets
unpack("document.mdz", Some("output/"))?;
Ok(())
}§MDZ Format Structure
document.mdz (ZIP archive)
├── index.md # Updated markdown with relative asset links
├── manifest.json # Metadata and asset mapping
└── assets/ # Organized asset files
├── images/
├── videos/
├── audio/
└── files/§Asset Handling
The library automatically processes:
- Network Images: Downloaded asynchronously with UUID filenames
- Local Files: Copied with conflict resolution (counter suffixes)
- Link Updates: Markdown links are updated to use relative paths (
./assets/...) - Metadata: Complete manifest.json with asset mapping and document info