#markdown #zip #archive #cli

app mdz

CLI tool for MDZ (Markdown Zip) format - packs and unpacks markdown documents with embedded assets

2 stable releases

Uses new Rust 2024

1.1.0 Dec 13, 2025
1.0.0 Dec 13, 2025

#2080 in Command line utilities

MIT license

65KB
725 lines

MDZ - The New File Format for Self-Contained Markdown Documents ๐Ÿš€

Crates.io Crates.io VS Code Marketplace License: MIT

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

๐Ÿ’ก 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

![Local photo](./photos/destination.jpg)
![Map from service](https://maps.example.com/location)
![Embedded video](./videos/tour.mp4)

<!-- 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
![Screenshot 1](./screenshots/step1.png)

## Video Tutorial
![Tutorial video](./videos/exercise1.mp4)

## 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 .md file โ†’ "Export as MDZ"
  • Unpack: Right-click .mdz file โ†’ "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:

  1. ๐Ÿ› Bug Reports: Open issues with detailed description
  2. ๐Ÿ’ก Feature Requests: Suggest improvements with use cases
  3. ๐Ÿ”ง Pull Requests: Ensure tests pass and code follows project style
  4. ๐Ÿ“š 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