#Processing rules and safety contract
This page is the behaviour contract for Make Markdown Library. It describes, in order, what the tool does and which files it may read, skip, write, back up, overwrite, or refuse to touch.
#Default paths
If you run:
make-markdown-library makethen the source is:
sources/relative to the current working directory, and the output library is:
markdown-library.mdrelative to the current working directory.
Set the source to a folder:
make-markdown-library make my-folderSet the source to a single file:
make-markdown-library make my-file.pdfSet the source to a ZIP archive:
make-markdown-library make archive.zipSet the output file explicitly:
make-markdown-library make my-folder -o out/library.mdOr provide a destination folder as the second positional path:
make-markdown-library make my-folder out/Or provide a destination Markdown file as the second positional path:
make-markdown-library make my-folder out/library.mdIf the destination path has a Markdown suffix, it is treated as the exact output file. Otherwise, it is treated as a folder and the tool writes markdown-library.md inside it.
#Output files
For a library output named:
library.mdthe companion outputs are:
library-manifest.md
library.index.json
library.index.yaml # only with --index-format yaml or both
library-files/ # only with --individual-files#Step-by-step processing order
The make command follows this process:
- Resolve the source path.
- Resolve the output library path.
- Resolve companion paths: manifest, JSON/YAML index, and optional individual output directory.
- Check unsafe path combinations.
- Apply overwrite or backup policy for output files.
- Build the exclusion list.
- Walk the source recursively, or process the single source file.
- Safely extract ZIP files and nested ZIP files.
- Classify each found file.
- Apply Markdown policy.
- Compute SHA-256 and short fingerprint.
- Skip duplicates unless
--allow-duplicatesis set. - Convert, import, or directly ingest the file.
- Validate converter output.
- Apply fallback routing where configured.
- Write the combined library.
- Write the manifest.
- Write the JSON/YAML index.
- Write individual Markdown files if requested.
- Print the summary.
#Overwrite rules
The make command is non-destructive by default.
If any output file already exists, make refuses to run unless you choose one of these behaviours:
--overwriteReplace existing library, manifest, and index outputs without backups.
--backup-existingCreate backups first, then replace the outputs.
Backups are written next to the original file, for example:
library.backup.md
library-manifest.backup.md
library.index.backup.jsonIf a backup already exists, numbered backup names are used.
#Source and destination in the same folder
It is OK for the source folder and output folder to be the same folder:
make-markdown-library make project project --backup-existingThe tool excludes its own current output library, manifest, index files, and individual output directory from the scan.
It is not OK for a single source file and the output file to be the same exact file:
make-markdown-library make notes.md -o notes.mdThat is refused.
#Excluded generated outputs
Unless --include-generated is set, the tool skips:
current output library file
current manifest file
current JSON/YAML index files
current individual output directory
*.index.json
*.index.yaml
*.index.yml
*-manifest.md
Markdown split files starting with <!-- source:This prevents recursive libraries and repeated ingestion of generated Markdown.
#Supported source files
The tool handles these directly:
.md, .markdown
.txt, .csv, .json, .jsonl, .xml, .logMarkItDown-supported inputs in this repository include:
.doc, .docx, .ppt, .pptx, .xls, .xlsx, .pdf,
.html, .htm, .rtf, .txt, .csv, .json, .jsonl, .xml, .logLiteParse-supported inputs in this repository include:
.pdf, .doc, .docx, .ppt, .pptx, .xls, .xlsx,
.odt, .ods, .odp,
.png, .jpg, .jpeg, .tif, .tiff, .bmp, .webpZIP files are containers, not source sections. They are extracted safely and the files inside are processed.
Unsupported files are recorded as skipped in the manifest/index.
#Markdown files
Normal Markdown files are first-class source files. They are read directly and are not sent through MarkItDown or LiteParse.
Default policy:
--md-policy includeThis means:
- normal
.mdfiles are included directly; - existing generated Markdown libraries are imported as source sections;
- generated manifests, indexes, and split files are skipped.
Other policies:
--md-policy import-libsImport sections from existing Markdown libraries, but skip ordinary Markdown files.
--md-policy skipSkip Markdown files entirely.
#JSON and YAML files
Normal .json files are included as direct text inputs.
Generated index files are skipped by default:
*.index.json
*.index.yaml
*.index.ymlNormal .yaml and .yml files are not currently source types in v3.1, so they are skipped as unsupported unless support is added later.
#Duplicate handling
Duplicates are detected by file content, not filename.
The tool computes a full SHA-256 hash and a short visible fingerprint. By default, only the first source with a given fingerprint is included. Later duplicates are recorded as skipped:
not added: duplicate source fingerprintTo include duplicate content anyway:
--allow-duplicates#Adding to an existing library
The add command reads existing source fingerprints from the library. New sources with matching fingerprints are skipped unless --allow-duplicates is used.
By default, add backs up the existing library before modifying it. To disable that:
make-markdown-library add library.md new-files --no-backup-existingadd appends new sections. It does not replace old sections with the same filename. If a source changed and you want replacement, remove the old section first or rebuild from an index.
#Rebuilds
The rebuild command reads a previous JSON index, compares current source hashes, and reuses unchanged sections where possible.
By default, rebuild backs up existing outputs before replacing them.
Use dry run to inspect changes without writing:
make-markdown-library rebuild library.index.json --dry-runUse --no-backup-existing --overwrite if you want to replace without backups.
#Individual Markdown files
With:
--individual-filesthe tool writes one Markdown file per included source into:
library-files/These split files are generated outputs. They start with a source marker:
<!-- source: ... -->On later runs, generated split files are skipped by default and may be overwritten safely by new generated split files.
Existing user-authored Markdown files are protected. If a generated split file would collide with an existing non-generated Markdown file, the tool chooses a numbered filename instead:
project.md # existing user file, preserved
project-2.md # generated outputTo deliberately allow overwrite of non-generated split output files:
--overwrite-individual#Individual directory safety
The default split directory is safe because it is separate from the source files and is excluded from future scans.
This is refused by default:
make-markdown-library make project -o project/library.md --individual-dir projectbecause it writes individual generated Markdown directly into the source folder and can collide with real Markdown sources.
To allow it intentionally:
--allow-individual-in-sourceA safer choice is:
--individual-dir project/converted-mdCustom individual output directories are excluded from source scanning on the same run.
#Generated output cleanup
The tool does not delete arbitrary files from the split directory.
To remove old generated split files before writing new ones:
--clean-individual-dirThis removes only generated split Markdown files with the source marker. It does not remove user-authored Markdown.
#Summary contract
By default, Make Markdown Library:
- reads source files but does not modify them;
- refuses to overwrite existing main outputs during
make; - backs up existing libraries during
addandrebuild; - excludes generated outputs from scanning;
- includes ordinary Markdown files directly;
- skips generated manifests, indexes, and split Markdown files;
- protects user-authored Markdown from individual-file collisions;
- refuses source-file-equals-output-file;
- refuses individual output directly in the source folder unless explicitly allowed.