#[ must_use ]
#[ inline ]
pub fn strip_fences( stdout : &str ) -> String
{
let lines : Vec< &str > = stdout.lines().collect();
let first_fence = lines.iter().position( | l | l.trim_start().starts_with( "```" ) );
let last_fence = lines.iter().rposition( | l | l.trim_start().starts_with( "```" ) );
match ( first_fence, last_fence )
{
( Some( f ), Some( l ) ) if f < l =>
{
let body = lines[ f + 1 .. l ].join( "\n" );
if stdout.ends_with( '\n' ) { format!( "{body}\n" ) } else { body }
}
_ => stdout.to_string(),
}
}