Skip to main content

emit_code_info_attrs

Function emit_code_info_attrs 

Source
pub fn emit_code_info_attrs(
    builder: &mut impl InlineSink,
    text: &str,
    carve_first_class_as_language: bool,
) -> bool
Expand description

Structure a code-block info-string region containing a {...} attribute block into ATTR_* children wrapping the source bytes, the same way emit_attribute_node does — but with a language carve-out: when carve_first_class_as_language is set, the first .class component is emitted as TEXT "." + CODE_LANGUAGE <lang> (Pandoc’s {.python …} language-first shape) instead of an ATTR_CLASS.

text is the full region that may surround the braces with gap bytes (e.g. " {.numberLines}" after a shortcut language). The {/} and any surrounding/interior gap bytes are emitted as gap tokens so node.text() reconstructs text exactly. Returns true when it structured the block, and false — having emitted nothing — when text has no {...} or its body is unrecognized (empty/whitespace-only), so callers fall back to a single opaque token and preserve the prior shape.

A leading =format raw marker is never carved as a language; the raw case is handled before this is reached, but the carve defensively skips =-prefixed components.