src2md
Turn source/text files into a single Markdown document — or extract them back. Built with Rust 2024 edition.
Warning
This project is in early development and may change rapidly.
AI (ChatGPT) has been extensively used in the design and implementation of this codebase.
Review carefully before using in production or contributing.
Features
- Recursively scans directories to find files.
- Supports
.src2md.ignore,.gitignore, or a custom ignore file. - Option to include specific files or directories.
- Wraps content in Markdown code blocks with syntax highlighting.
- Uses dynamic backtick fencing to safely include Markdown and code.
- Lists binary files by their paths (content omitted).
- Zero-copy file reading using memory-mapped files.
- Extracts files back from a generated Markdown file (with
--extract). - Usable as a command-line tool or Rust library.
Installation
Or build from source:
CLI Usage
Common Options
| Flag | Description |
|---|---|
-o, --output FILE |
Output Markdown file (default: {project}_content_{timestamp}.md) |
-i, --ignore FILE |
Ignore file path (.src2md.ignore or .gitignore by default) |
[PATHS] |
Files or directories to include |
--extract FILE.md |
Extracts original files from a .md file |
--extract-path DIR |
Target folder to extract files into |
Examples
# Default: all files in current dir → Markdown
# Specify output path
# Use custom ignore file
# Include only certain files
# Extract files back from Markdown
Library Usage
Add to your Cargo.toml:
= "0.1"
Generate Markdown
use ;
use PathBuf;
use HashSet;
async
Extract Files from Markdown
use extract_from_markdown;
use PathBuf;
async
Cargo Features
Planned (not yet active):
highlight: syntax highlighting withsyntectserde: config serializationcli-only: trim library for tiny builds
Changelog
v0.1.1
- CLI and library mode
- Safe Markdown code fencing
- Extract mode with
--extractand--extract-path
v0.1.0
- Initial release
- Memory-mapped (zero-copy) file reading
Contributors
- Matias Hiltunen – Author
- You? Submit a pull request!
License
MIT © Matias Hiltunen