Skip to main content

Validation, sanitization and metrics for Markdown manuscripts.

Project description

manuscript-tools

A QA toolkit for German Markdown manuscripts. Validates style, sanitizes encoding, converts quotation marks, and measures readability.

Deutsche Version | Wiki

Installation

pip install manuscript-tools

Or as project dependency:

poetry add manuscript-tools

Commands

Command Description
ms-check Style checks (6 core rules, --strict adds 3 prose rules)
ms-sanitize Fix encoding, strip invisible chars, normalize Unicode
ms-quotes Convert quotation marks to German typographic style „ " ‚ '
ms-dashes Rewrite faked dashes (--, spaced hyphen) to a real dash (--to em|en)
ms-format Fix broken bold/italic caused by line-wrapping formatters
ms-metrics Word counts, sentence analysis, Flesch-DE readability score
ms-validate Full QA pipeline (sanitize + quotes + formatting + check + readability)

Quick start

# Full QA pipeline
ms-validate manuscript/

# Style check only (core rules)
ms-check manuscript/

# Style check with prose analysis (filler words, passive voice, sentence length)
ms-check manuscript/ --strict

# Readability report
ms-metrics manuscript/

# Fix quotation marks (dry-run)
ms-quotes manuscript/ --dry-run

# Fix broken bold/italic formatting (dry-run)
ms-format manuscript/ --dry-run

# Rewrite -- and spaced hyphens to en-dashes (German typography, dry-run)
ms-dashes manuscript/ --to en --dry-run

File selection

Not limited to Markdown. Directories are scanned with the glob **/*.md by default; a single file passed as argument is processed as-is, regardless of extension:

# Single file: no glob filter applied
ms-check brief.txt

# Directory with other extensions: override the glob
ms-sanitize docs/ --include '**/*.txt'
ms-check kapitel/ --include '**/*.tex' --exclude '**/build/**'

Files must be UTF-8 text (txt, tex, rst, html, ...) — binary formats like docx or pdf are not supported. The broken-formatting rule checks Markdown **/* markers; for non-Markdown files it is harmless, or disable it via disable = ["broken-formatting"] in the configuration.

Example

A manuscript with typical artifacts from AI tools, copy-paste, or code formatters — line 1 contains an invisible zero-width space (U+200B) after "Test":

Das ist ein Test mit unsichtbarem Zeichen.

Er sagte: "Hallo Welt" und ging.

Dies ist ein **
wichtiger Satz** im Text.

ms-check reports every problem with file, line, and rule — invisible characters are named by codepoint:

$ ms-check kapitel-01.md
FAIL: kapitel-01.md:1 [no-invisible-chars] Unsichtbare Unicode-Zeichen gefunden: U+200B ZERO WIDTH SPACE
FAIL: kapitel-01.md:3 [non-german-quotes] Nicht-deutsche Anführungszeichen gefunden
FAIL: kapitel-01.md:5 [broken-formatting] Oeffnendes ** am Zeilenende (Formatierung gebrochen)
------------------------------------------------------------
Dateien: 1, Woerter: 21
Status: FEHLER (1 Dateien, 3 Verstoss(e))

Fix step by step — every fixer supports --dry-run (preview) and writes .bak backups:

$ ms-sanitize kapitel-01.md
CLEANED: kapitel-01.md
$ ms-quotes kapitel-01.md
FIXED: kapitel-01.md (1 Ersetzung(en))
$ ms-format kapitel-01.md
FIXED: kapitel-01.md (1 bold, 0 italic)
$ ms-check kapitel-01.md
OK: kapitel-01.md (20 Woerter)
Status: OK

Result:

Das ist ein Test mit unsichtbarem Zeichen.

Er sagte: „Hallo Welt“ und ging.

Dies ist ein **wichtiger Satz** im Text.

Or run the whole pipeline in one go: ms-validate kapitel-01.md --fix.

Rules

Core (always active):

no-dashes, no-invisible-chars, no-repeated-words, no-double-spaces, non-german-quotes, broken-formatting

Prose (with --strict or ms-validate):

max-sentence-length, filler-words-de, passive-voice-de

Opt-in (via rules = ["faked-dashes"] in the configuration):

faked-dashes — flags -- and spaced hyphens standing in for a real dash. By design it contradicts no-dashes (one forbids dashes, the other demands correctly typed ones), so enable one and disable the other. ms-dashes --to em|en rewrites the findings:

Er kam -- wie immer -- viel zu spaet.      # before
Er kam – wie immer – viel zu spaet.        # after ms-dashes --to en
Seiten 12 - 15 behandeln das Thema.        # numeric ranges stay untouched
[x](https://img.shields.io/badge/a--b)     # URLs and badge slugs stay untouched

Custom rules are simple callables with the signature (text: str, path: Path) -> list[StyleViolation]. See the Wiki for a step-by-step tutorial.

Configuration

Configure via [tool.manuscript-tools] in your pyproject.toml:

[tool.manuscript-tools]
rules = ["max-sentence-length"]          # merge with defaults
disable = ["passive-voice-de"]           # remove from active set
max-sentence-words = 30                  # default: 40
flesch-target = [65, 80]                 # warn if outside range
filler-words-extra = ["definitiv", "absolut"]  # extend filler list

No config = all defaults. rules merges with defaults (union). disable removes from the active set and takes precedence over rules. See the Wiki for details.

Readability

ms-metrics computes the Flesch-DE reading ease score (Amstad, 1978) with German-optimized syllable counting. Score interpretation:

Score Level Typical use
80-100 Very easy Children's books
60-80 Easy to medium Fiction, non-fiction
30-60 Difficult Journalism, academic
0-30 Very difficult Legal, scientific

Development

git clone https://github.com/astrapi69/manuscript-tools.git
cd manuscript-tools
make install-dev
make ci          # lint + format check + 182 tests

Documentation

Full documentation is available in the Wiki:

License

BSD 3-Clause. See LICENSE.

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

manuscript_tools-0.8.1.tar.gz (29.7 kB view details)

Uploaded Source

Built Distribution

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

manuscript_tools-0.8.1-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

Details for the file manuscript_tools-0.8.1.tar.gz.

File metadata

  • Download URL: manuscript_tools-0.8.1.tar.gz
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.13 Linux/7.0.0-28-generic

File hashes

Hashes for manuscript_tools-0.8.1.tar.gz
Algorithm Hash digest
SHA256 7e7208be2f5b74f22b7b1391a7074f25ef4d416b132b7b5c392e8565d3b408bd
MD5 1884c88e61ad225359ace8d9dc8045a9
BLAKE2b-256 79d439877da9d1dad8767c438a5c637763398769dcc34f7fcb68f5c2660e7a26

See more details on using hashes here.

File details

Details for the file manuscript_tools-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: manuscript_tools-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 33.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.13 Linux/7.0.0-28-generic

File hashes

Hashes for manuscript_tools-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 74b3c788fca32e27a4db455b60d999af3c4fd91f5d0306654661370224c0cb08
MD5 4eb833a576c6f68d74892795887dfd16
BLAKE2b-256 a2189d4ee654d0c0d597c943873f4bbdd9861a4a81b8524a1345df123bb205d8

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