pub fn extract_lang_label(text: &str) -> Option<String>Expand description
Extracts the language label from a Markdown-style code block.
This function looks for the first occurrence of a triple backtick (“```”), then captures everything from immediately after it up to the next newline. That captured substring is returned as the language label (e.g., “rust”, “python”).
§Arguments
text- A string slice that may contain a Markdown code block.
§Returns
Some(String)containing the language label if a code block is found and a newline follows the opening backticks.Noneif no opening backticks or newline is found.
§Example
let input = "Here is code:\n```rust\nfn main() {}\n```";
let lang = ys1r::markdown::extract_lang_label(input);
assert_eq!(lang, Some("rust".to_string()));