Skip to main content

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, wordword,word
  • Note: textNote:text
  • word; wordword;word
  • sentence. Nextsentence.Next
  • word (detail)word(detail)
  • and / orand/or
  • word -- wordword--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 1Reviewer-1, Reviewer AReviewer-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

  1. Segment: Split input into protected regions (code blocks, inline code) and compressible regions (text, math)
  2. Compress: Apply mode-specific rules to each segment type
  3. Reassemble: Join segments and apply global optimizations

Code blocks and inline code are never modified.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdziper-0.1.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mdziper-0.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

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

Hashes for mdziper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 78d64085b8a22252001228aa3246af06f5cf6c1335849da6aa1847b2b1566fd5
MD5 e7ae9b20db6f6144dcc87d2f78120d5d
BLAKE2b-256 c03957a71111f88670fdea51ebaedb9843d9cda3e908e503595f365eefe734b9

See more details on using hashes here.

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

Hashes for mdziper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11195edd4415e6f0872d955b0c9cd267b13450f4bcadfd9893e5231fa04b339c
MD5 4ca5ca98f894e45997fc79357236db38
BLAKE2b-256 04dc58336cba155d9edac7fb306915800a3f612c450609e17c70b549f492d34e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page