pub struct Attrlist<'src> { /* private fields */ }Expand description
The source text that’s used to define attributes for an element is referred to as an attrlist. An attrlist is always enclosed in a pair of square brackets. This applies for block attributes as well as attributes on a block or inline macro. The processor splits the attrlist into individual attribute entries, determines whether each entry is a positional or named attribute, parses the entry accordingly, and assigns the result as an attribute on the node.
Implementations§
Source§impl<'src> Attrlist<'src>
impl<'src> Attrlist<'src>
Sourcepub fn attributes(&'src self) -> Iter<'src, ElementAttribute<'src>>
pub fn attributes(&'src self) -> Iter<'src, ElementAttribute<'src>>
Returns an iterator over the attributes contained within this attrlist.
Sourcepub fn named_attribute(
&'src self,
name: &str,
) -> Option<&'src ElementAttribute<'src>>
pub fn named_attribute( &'src self, name: &str, ) -> Option<&'src ElementAttribute<'src>>
Returns the first attribute with the given name.
Sourcepub fn nth_attribute(
&'src self,
n: usize,
) -> Option<&'src ElementAttribute<'src>>
pub fn nth_attribute( &'src self, n: usize, ) -> Option<&'src ElementAttribute<'src>>
Returns the given (1-based) positional attribute.
IMPORTANT: Named attributes with names are disregarded when counting.
Sourcepub fn named_or_positional_attribute(
&'src self,
name: &str,
index: usize,
) -> Option<&'src ElementAttribute<'src>>
pub fn named_or_positional_attribute( &'src self, name: &str, index: usize, ) -> Option<&'src ElementAttribute<'src>>
Returns the first attribute with the given name or index.
Some block and macro types provide implicit mappings between attribute names and positions to permit a shorthand syntax.
This method will search by name first, and fall back to positional indexing if the name doesn’t yield a match.
Sourcepub fn id(&'src self) -> Option<Span<'src>>
pub fn id(&'src self) -> Option<Span<'src>>
Returns the ID attribute (if any).
You can assign an ID to a block using the shorthand syntax, the longhand syntax, or a legacy block anchor.
In the shorthand syntax, you prefix the name with a hash (#) in the
first position attribute:
[#goals]
* Goal 1
* Goal 2In the longhand syntax, you use a standard named attribute:
[id=goals]
* Goal 1
* Goal 2In the legacy block anchor syntax, you surround the name with double square brackets:
[[goals]]
* Goal 1
* Goal 2Trait Implementations§
impl<'src> Eq for Attrlist<'src>
impl<'src> StructuralPartialEq for Attrlist<'src>
Auto Trait Implementations§
impl<'src> Freeze for Attrlist<'src>
impl<'src> RefUnwindSafe for Attrlist<'src>
impl<'src> Send for Attrlist<'src>
impl<'src> Sync for Attrlist<'src>
impl<'src> Unpin for Attrlist<'src>
impl<'src> UnwindSafe for Attrlist<'src>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)