Thanks to visit codestin.com
Credit goes to GitHub.com

Skip to content
/ mdz Public

MDZ (Markdown Zip) A portable, open archive format for Markdown documents with embedded media.

License

Notifications You must be signed in to change notification settings

wflixu/mdz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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

About

MDZ (Markdown Zip) A portable, open archive format for Markdown documents with embedded media.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •