Skip to main content

Crate prompt_fence_strip

Crate prompt_fence_strip 

Source
Expand description

§prompt-fence-strip

Strip code fences, leading prose (“Sure, here you go:”), and trailing chatter (“Let me know if you need anything else!”) from LLM output so the structured payload inside survives.

§Example

use prompt_fence_strip::strip_fences;
let raw = "Sure!\n```json\n{\"a\":1}\n```\nLet me know!";
assert_eq!(strip_fences(raw), "{\"a\":1}");

Functions§

strip_fences
Strip code fences and surrounding prose. Returns the inner content of the first fenced block. If no fenced block is found, the input is returned trimmed of surrounding whitespace.
strip_fences_cow
Strip without copying when no change is needed. Returns a borrowed slice into s when possible, else an owned String.