Skip to main content

code_fence_lang

Function code_fence_lang 

Source
pub fn code_fence_lang(line: &str) -> Option<String>
Expand description

Parse a fenced code-block opener line and return the language tag.

Why: We need to distinguish opening fences (```bash) from closing fences (```) and from non-fence content. Returning Some(lang) for openers (including Some("") for bare openers) and None for anything that isn’t a fence line at all lets the renderer drive its state machine cleanly. What: Trims the line; if it starts with three backticks, returns the trailing tag (lowercased) — empty string for bare openers, None for anything that isn’t a fence line at all. Test: tests::code_fence_lang_recognizes_openers_and_closers.