asciidoc_parser::attributes

Struct Attrlist

Source
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>

Source

pub fn attributes(&'src self) -> Iter<'src, ElementAttribute<'src>>

Returns an iterator over the attributes contained within this attrlist.

Source

pub fn named_attribute( &'src self, name: &str, ) -> Option<&'src ElementAttribute<'src>>

Returns the first attribute with the given name.

Source

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.

Source

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.

Source

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 2

In the longhand syntax, you use a standard named attribute:

[id=goals]
* Goal 1
* Goal 2

In the legacy block anchor syntax, you surround the name with double square brackets:

[[goals]]
* Goal 1
* Goal 2

Trait Implementations§

Source§

impl<'src> Clone for Attrlist<'src>

Source§

fn clone(&self) -> Attrlist<'src>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'src> Debug for Attrlist<'src>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'src> HasSpan<'src> for Attrlist<'src>

Source§

fn span(&'src self) -> &'src Span<'src>

Return a Span describing the syntactic element’s location within the source string/file.
Source§

impl<'src> PartialEq for Attrlist<'src>

Source§

fn eq(&self, other: &Attrlist<'src>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'src> Eq for Attrlist<'src>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.