Skip to main content

strip_code_fences

Function strip_code_fences 

Source
pub fn strip_code_fences(input: &str) -> &str
Expand description

Strip a Markdown code fence wrapper from the input.

If the (trimmed) input is a single fenced block — ``` or ```json etc. — the inner content is returned. A missing closing fence (truncated output) is tolerated. Inputs that are not a single fenced block are returned unchanged.

§Example

use fuzzy_parser::strip_code_fences;

let output = "```json\n{\"a\": 1}\n```";
assert_eq!(strip_code_fences(output), "{\"a\": 1}");