2 stable releases
Uses new Rust 2024
| 1.1.0 | Dec 13, 2025 |
|---|---|
| 1.0.0 | Dec 13, 2025 |
#2080 in Command line utilities
65KB
725 lines
MDZ - The New File Format for Self-Contained Markdown Documents ๐
MDZ (Markdown Document Zip) is a revolutionary new file format designed specifically for sharing Markdown documents with embedded assets. Tired of broken images, missing files, and complex folder structures when sharing your Markdown content? MDZ solves the fundamental challenge of modern content distribution: creating portable, self-contained documents that work perfectly everywhere.
๐ฏ The Problem MDZ Solves
Traditional Markdown Sharing Problems:
- โ Broken image links when documents are moved or shared
- โ Complex folder structures that must be maintained
- โ Network dependencies that make offline viewing impossible
- โ Asset management headaches for content creators
- โ Distribution requires multiple files and careful organization
MDZ Solution:
- โ Single File, Complete Story - Everything embedded in one .mdz file
- โ Universal Portability - Works anywhere, no dependencies required
- โ Smart Asset Processing - Automatically handles both local and network resources
- โ Professional Distribution - Share like a PDF, but with Markdown's flexibility
- โ Future-Proof Content - Self-contained files that never break over time
๐ Why MDZ is Different
MDZ isn't just another compression tool - it's a thoughtfully designed file format that understands how people actually create and share content:
๐ For Content Creators
- Bloggers: Share posts with embedded images without hosting hassles
- Technical Writers: Distribute documentation with diagrams and examples
- Authors: Send book chapters with media to editors and publishers
- Educators: Create lesson plans with embedded resources
- Developers: Share READMEs with screenshots and demos
๐ ๏ธ For Tool Developers
- Standardized Format: Open specification for consistent implementation
- Rich Ecosystem: Rust library, CLI tool, and VS Code extension
- Extensible Design: Ready for future enhancements and integrations
- Cross-Platform: Works on Windows, macOS, and Linux
โจ Features
๐ Core Functionality
- ๐๏ธ MDZ Format: Custom ZIP-based format for bundling Markdown with images, videos, audio, and other files
- ๐ง Rust Library: High-performance core library (
mdz-rs) with async image downloading and smart asset handling - ๐ป CLI Tool: Full-featured command-line utility (
mdz) for packing and unpacking MDZ files - โก VS Code Extension: First-class editor integration with export/unpack capabilities (
mdz-vscode)
๐ฏ Smart Features
- ๐ Network Images: Automatically downloads remote images and saves with UUID filenames
- ๐ Local Files: Intelligent copying of local assets with conflict resolution
- ๐ Relative Links: Uses relative paths (
./assets/...) for maximum compatibility - โช Backward Compatibility: Handles legacy MDZ files without filename field
- ๐ Metadata: Complete manifest.json with asset mapping and document metadata
๐๏ธ Project Structure
.
โโโ LICENSE
โโโ README.md
โโโ CLAUDE.md
โโโ mdz-spec.md # ๐ MDZ format specification
โโโ mdz/ # ๐ป CLI tool crate
โ โโโ Cargo.toml
โ โโโ src/
โ โโโ main.rs # CLI interface
โ โโโ tests.rs # CLI tests
โโโ mdz-rs/ # ๐ง Core library crate
โ โโโ Cargo.toml
โ โโโ src/
โ โโโ lib.rs # Main library implementation
โ โโโ tests.rs # Unit tests
โโโ mdz-vscode/ # โก VS Code extension
โ โโโ package.json
โ โโโ src/
โ โ โโโ extension.ts # Extension entry point
โ โ โโโ commands/
โ โ โ โโโ export.ts # Export functionality
โ โ โ โโโ unpack.ts # Unpack functionality
โ โ โโโ utils/
โ โ โโโ mdzCli.ts # CLI integration
โ โ โโโ fileUtils.ts # File utilities
โ โโโ out/ # Compiled JavaScript
โโโ tests/ # ๐งช Test files and demos
โโโ integration_test.rs
โโโ demo/
๐ฆ Components
mdz-rs/: Core Rust library (lib.rs) - 787 linesmdz/: CLI tool (main.rs) - 191 linesmdz-vscode/: VS Code extension - 448 lines TypeScript- mdz-spec.md: Complete format specification and usage guide
๐ก Real-World Use Cases
๐ Technical Documentation
<!-- Before: Multiple files to manage -->
documentation/
โโโ README.md
โโโ images/
โ โโโ architecture.png
โ โโโ workflow.png
โ โโโ deployment.png
โโโ diagrams/
โโโ sequence.uml
โโโ network.graphml
<!-- After: Single file to share -->
documentation.mdz โ Contains everything!
๐จ Blog Post with Rich Media
# My Travel Blog Post



<!-- MDZ automatically: -->
<!-- โข Downloads map image and saves locally -->
<!-- โข Bundles all media in the file -->
<!-- โข Updates all links to work offline -->
๐ Educational Materials
# Programming Tutorial
## Exercise 1

## Video Tutorial

## Source Code
[Download examples](./code/examples.zip)
๐ Before vs After MDZ
| Scenario | Before MDZ | After MDZ |
|---|---|---|
| Sharing with colleague | Send zip file + instructions | Send single .mdz file |
| Uploading to platform | Multiple files + manual linking | Upload single .mdz file |
| Backup content | Track folder + assets separately | One .mdz file contains everything |
| Offline viewing | Broken network images | All images work offline |
| Version control | Large repos with media assets | Small repos with single files |
๐ MDZ vs Other Solutions
| Solution | โ Advantages | โ Limitations |
|---|---|---|
| MDZ | Single file, smart processing, offline capable | Requires MDZ-aware tools |
| ZIP folders | Universal compatibility | Manual asset management |
| Git repos | Version control | Complex setup, requires internet |
| Static sites | Beautiful presentation | Hosting dependency, maintenance |
| PDF export | Universal viewing | Lost Markdown editing capability |
๐ Installation
๐ฆ From Crates.io
# Install CLI tool
cargo install mdz
# Library usage in Cargo.toml
mdz-rs = "1.1.0"
๐จ From Source
# Clone and build
git clone https://github.com/wflixu/mdz.git
cd mdz
cargo install --path .
# Build library only
cargo build --release -p mdz-rs
โก VS Code Extension
# Install from marketplace
code --install-extension wflixu.mdz
# Or install from VSIX
code --install-extension mdz-vscode/mdz-1.1.0.vsix
๐ Usage
๐ป CLI Tool
# Export markdown to MDZ
mdz pack document.md -o document.mdz
# Export with custom name
mdz pack document.md -o my-doc.mdz
# Unpack MDZ to current directory
mdz unpack document.mdz
# Unpack to specific directory
mdz unpack document.mdz -o output/
๐ข Rust Library
use mdz_rs::{pack, unpack};
// Async pack function
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
pack("document.md", "document.mdz").await?;
unpack("document.mdz", Some("output/"))?;
Ok(())
}
โก VS Code Extension
- Export: Right-click
.mdfile โ "Export as MDZ" - Unpack: Right-click
.mdzfile โ "Unpack MDZ" - Quick Actions: Export/unpack buttons in editor title bar
- Commands:
Ctrl+Shift+Pโ "MDZ: Export as MDZ"
๐ MDZ File 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/
๐ฏ Key Features
- โ Standard ZIP: Can be extracted with any ZIP tool
- โ
Relative Links: Uses
./assets/...paths for maximum compatibility - โ Smart Asset Handling: Auto-download network images, copy local files
- โ UUID Filenames: Network images use UUID names to avoid conflicts
- โ Metadata Support: Complete manifest with document and asset information
- โ Backward Compatible: Handles legacy files (v1.0.0) seamlessly
๐ Specification
See mdz-spec.md for complete format specification and implementation details.
๐งช Development
๐๏ธ Build & Test
# Build all components
cargo build
# Run tests
cargo test
# Run with verbose output
cargo test -- --nocapture
# Integration tests
cargo test --test integration_test
๐ง VS Code Extension Development
cd mdz-vscode
pnpm install
pnpm run compile
pnpm exec vsce package
๐ Project Stats (v1.1.0)
- Core Code: 1,426 lines (Rust + TypeScript)
- Tests: 491 lines (unit + integration tests)
- Languages: Rust (1k+ lines), TypeScript (448 lines)
- Components: Core library, CLI tool, VS Code extension
๐ค Contributing
Contributions are welcome! Please:
- ๐ Bug Reports: Open issues with detailed description
- ๐ก Feature Requests: Suggest improvements with use cases
- ๐ง Pull Requests: Ensure tests pass and code follows project style
- ๐ Documentation: Help improve docs and examples
๐ ๏ธ Development Setup
git clone https://github.com/wflixu/mdz.git
cd mdz
cargo build
cargo test # Verify everything works
๐ License
This project is licensed under the MIT License. See LICENSE for details.
๐ Acknowledgments
- Built with Rust for performance and safety
- VS Code extension powered by TypeScript
- Inspired by the need for self-contained Markdown document sharing
- Community feedback and contributions for continuous improvement
Dependencies
~15โ25MB
~417K SLoC