Skip to main content

inline_code_spans

Function inline_code_spans 

Source
pub fn inline_code_spans(text: &str) -> Vec<InlineCode>
Expand description

HP.2: find every inline `code` span in text.

Why this exists at all. Help pages are markdown, but the markdown block grammar has no code_span node — that lives in the inline grammar, which is not wired up. So the grammar emits nothing for `gr`, and every keybinding, command and action in every help page rendered as plain prose with visible backticks.

Why it returns spans rather than styles. Deciding whether `gr` is a key you press needs the live keymap, which lives in the host, not here. This function does the part that is pure text — where the literals are — and the host classifies each one. Same division as link_highlights: help finds the thing, the host colours it.

Fenced code blocks are skipped: their contents are already styled as a block, and a stray backtick inside a shell example is not a literal.