Skip to main content

replace_fence_lang

Function replace_fence_lang 

Source
pub fn replace_fence_lang(body: &str, lang_replacement: &str) -> String
Expand description

Strip a single ```lang fence pair from body, returning the inner code lines. Replaces the leading ```rust (or any other tag) with lang_replacement, leaving the rest of the body unchanged.

When no fence is present the body is returned unchanged. Used by emitters that need to convert ```rust examples into ```typescript / ```python / ```swift etc.