Compress Markdown to reduce word count while preserving content
Project description
mdziper
Compress Markdown source text to reduce word count while preserving content. Designed for academic peer review rebuttals with strict word limits.
Install
pip install mdziper
Usage
Python API
from mdziper import compress
text = open("rebuttal.md").read()
# Standard mode: rendered output is pixel-perfect identical
result = compress(text, mode="standard")
# Extreme mode: aggressive compression, may alter formatting
result = compress(text, mode="extreme")
print(result.text)
print(f"{result.original_words} → {result.compressed_words} words ({result.savings:.0%} saved)")
CLI
# Standard compression
mdziper input.md -o output.md
# Extreme compression with stats
mdziper input.md --extreme --stats
# Pipe from stdin
cat input.md | mdziper --extreme > output.md
# Skip specific rules
mdziper input.md --extreme --exclude E04 E16
# List all rules
mdziper --list-rules
Compression Modes
Standard Mode
Removes whitespace that doesn't affect Markdown rendering:
- Trailing whitespace on lines
- Extra blank lines
- Spaces inside table cells:
| cell |→|cell| - Spaces in LaTeX math:
$a + b = c$→$a+b=c$ - Spaces in LaTeX braces:
$\frac{ a }{ b }$→$\frac{a}{b}$ - Redundant spaces in link syntax
- Repeated inline links → reference-style links
Extreme Mode
All standard optimizations plus aggressive space removal. Markdown structure (headings, lists, code blocks, tables) is preserved — only cosmetic spaces are removed.
Punctuation spacing:
word, word→word,wordNote: text→Note:textword; word→word;wordsentence. Next→sentence.Nextword (detail)→word(detail)and / or→and/orword -- word→word--word
Headings:
- Numbered prefix:
## 1. Setup→## 1.Setup - Content underscores:
## Experimental Setup→## Experimental_Setup
Tables:
- Cell content hyphens:
|Base A|→|Base-A|
References:
[1]: Smith et al., "Deep Learning for X", NeurIPS 2023→[1]:Smith_et_al.,Deep_Learning_for_X,NeurIPS_2023
Common phrases:
Reviewer 1→Reviewer-1,Reviewer A→Reviewer-A
Note: Extreme mode produces minor visual differences but does not break Markdown rendering. Headings, lists, tables, and code blocks all render correctly.
How It Works
- Segment: Split input into protected regions (code blocks, inline code) and compressible regions (text, math)
- Compress: Apply mode-specific rules to each segment type
- Reassemble: Join segments and apply global optimizations
Code blocks and inline code are never modified.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mdziper-0.1.0.tar.gz.
File metadata
- Download URL: mdziper-0.1.0.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78d64085b8a22252001228aa3246af06f5cf6c1335849da6aa1847b2b1566fd5
|
|
| MD5 |
e7ae9b20db6f6144dcc87d2f78120d5d
|
|
| BLAKE2b-256 |
c03957a71111f88670fdea51ebaedb9843d9cda3e908e503595f365eefe734b9
|
File details
Details for the file mdziper-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mdziper-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11195edd4415e6f0872d955b0c9cd267b13450f4bcadfd9893e5231fa04b339c
|
|
| MD5 |
4ca5ca98f894e45997fc79357236db38
|
|
| BLAKE2b-256 |
04dc58336cba155d9edac7fb306915800a3f612c450609e17c70b549f492d34e
|