A Rust library to strip markdown fenced code blocks from text while preserving the inner content and leaving inline code blocks untouched.
Add this to your Cargo.toml:
[dependencies]
strip-codeblocks = "0.1.0"use strip_codeblocks::strip_codeblocks;
let markdown = "Some text.\n\n```rust\nfn main() {}\n```\n\nMore text with `inline code`.";
let result = strip_codeblocks(markdown);
// Result: "Some text.\n\nfn main() {}\n\nMore text with `inline code`."- Removes fenced code blocks (triple backticks: ```)
- Preserves the content inside code blocks
- Keeps inline code blocks (single backticks: `) intact
- Handles code blocks with or without language identifiers
MIT - see LICENSE file for details