| Crates.io | src2md |
| lib.rs | src2md |
| version | 0.1.4 |
| created_at | 2025-04-06 11:21:33.599562+00 |
| updated_at | 2025-04-06 11:52:14.745267+00 |
| description | Turn source code into a Markdown document with syntax highlighting, or extract it back. |
| homepage | https://github.com/MatiasHiltunen/src2md |
| repository | https://github.com/MatiasHiltunen/src2md |
| max_upload_size | |
| id | 1622824 |
| size | 49,791 |
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.
.src2md.ignore, .gitignore, or a custom ignore file.--extract).cargo install src2md
Or build from source:
git clone https://github.com/MatiasHiltunen/src2md.git
cd src2md
cargo build --release
src2md [OPTIONS] [PATHS]...
| 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 |
# Default: all files in current dir → Markdown
src2md
# Specify output path
src2md -o docs/code.md
# Use custom ignore file
src2md -i .customignore
# Include only certain files
src2md src/lib.rs src/main.rs
# Extract files back from Markdown
src2md --extract my_code.md --extract-path restored/
Add to your Cargo.toml:
src2md = "0.1"
use src2md::{Config, run_src2md};
use std::path::PathBuf;
use std::collections::HashSet;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = Config {
output_path: PathBuf::from("out.md"),
ignore_file: None,
specific_paths: HashSet::new(),
project_root: std::env::current_dir()?,
extract_input: None,
extract_path: None,
};
run_src2md(config).await
}
use src2md::extract_from_markdown;
use std::path::PathBuf;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
extract_from_markdown(&PathBuf::from("out.md"), Some(&PathBuf::from("restored/"))).await
}
Planned (not yet active):
highlight: syntax highlighting with syntectserde: config serializationcli-only: trim library for tiny builds--extract and --extract-pathMIT © Matias Hiltunen