strip_codeblocks

Function strip_codeblocks 

Source
pub fn strip_codeblocks(text: &str) -> String
Expand description

Strips fenced code blocks from markdown text while preserving the inner content.

This function removes markdown fenced code blocks (triple backticks) but keeps the content inside them. Inline code blocks (single backticks) are left untouched.

§Arguments

  • text - The markdown text containing code blocks to strip

§Returns

A new string with fenced code blocks removed, but their content preserved.

§Examples

use strip_codeblocks::strip_codeblocks;

let markdown = "Some text before.\n\n```rust\nfn example() {\n    println!(\"Hello\");\n}\n```\n\nSome text after with `inline code`.";

let result = strip_codeblocks(markdown);
// The fenced code block is removed, but its content remains
//Inline code is preserved