pub struct Group { /* private fields */ }Expand description
A { … } group — an argument, or a nested brace group.
Implementations§
Source§impl Group
impl Group
Sourcepub fn inner_text(&self) -> Option<SmolStr>
pub fn inner_text(&self) -> Option<SmolStr>
The literal text inside this group, with the enclosing braces dropped.
Concatenates the inner token text so content split across WORD/.///…
tokens (e.g. chapters/my_file, sec:intro) reassembles. Returns None when
the group holds non-token content (a nested command — not a flat literal) or a
parameter token (\ref{#1}, \eqref{##1} — a macro-parameter template whose
literal value exists only at expansion time).
Sourcepub fn inner(&self) -> Option<(TextRange, SmolStr)>
pub fn inner(&self) -> Option<(TextRange, SmolStr)>
The byte range of the content inside this group (the span between the
braces) together with that inner text — the location-aware counterpart to
Group::inner_text. The inner range runs from the first inner token’s start
to the last inner token’s end; an empty group ({}) yields a zero-width range
just after the {. Returns None under the same conditions as
Group::inner_text.
The text/range correspondence is exact: in the success path the group holds
only flat tokens, so its inner bytes are contiguous and per-key sub-ranges can
be sliced off the range by byte offset (used by the semantic builder to give
each key in a \cref{a,b} its own precise span).
Sourcepub fn inner_source(&self) -> String
pub fn inner_source(&self) -> String
The raw inner source of this group with its outer braces dropped, but all
interior text preserved — nested {…} braces included. Unlike
Group::inner_text, which bails on nested nodes, this reconstructs the
verbatim content needed for an xparse argument spec like {m O{0} m} (whose
{0} default parses as a nested GROUP). Trivia is kept verbatim; the caller
tokenizes the result.
Sourcepub fn command(&self) -> Option<Command>
pub fn command(&self) -> Option<Command>
The single COMMAND child wrapped in this group, if any.
Sourcepub fn command_name(&self) -> Option<SmolStr>
pub fn command_name(&self) -> Option<SmolStr>
The control-word name (leading \ stripped) of a single COMMAND wrapped in
this group, as in a \newcommand{\foo} name group. Returns None unless the
group’s only relevant child is exactly one control word.