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
Source

pub fn roles(&'src self) -> Vec<Span<'src>>

Returns any role attributes that were found.

You can assign one or more roles to blocks and most inline elements using the role attribute. The role attribute is a named attribute. Even though the attribute name is singular, it may contain multiple (space-separated) roles. Roles may also be defined using a shorthand (dot-prefixed) syntax.

A role:

  1. adds additional semantics to an element
  2. can be used to apply additional styling to a group of elements (e.g., via a CSS class selector)
  3. may activate additional behavior if recognized by the converter

TIP: The role attribute in AsciiDoc always get mapped to the class attribute in the HTML output. In other words, role names are synonymous with HTML class names, thus allowing output elements to be identified and styled in CSS using class selectors (e.g., sidebarblock.role1).

Source

pub fn options(&'src self) -> Vec<Span<'src>>

Returns any option attributes that were found.

The options attribute (often abbreviated as opts) is a versatile named attribute that can be assigned one or more values. It can be defined globally as document attribute as well as a block attribute on an individual block.

There is no strict schema for options. Any options which are not recognized are ignored.

You can assign one or more options to a block using the shorthand or formal syntax for the options attribute.

§Shorthand options syntax for blocks

To assign an option to a block, prefix the value with a percent sign (%) in an attribute list. The percent sign implicitly sets the options attribute.

§Example 1: Sidebar block with an option assigned using the shorthand dot
[%option]
****
This is a sidebar with an option assigned to it, named option.
****

You can assign multiple options to a block by prest fixing each value with a percent sign (%).

§Example 2: Sidebar with two options assigned using the shorthand dot
[%option1%option2]
****
This is a sidebar with two options assigned to it, named option1 and option2.
****
§Formal options syntax for blocks

Explicitly set options or opts, followed by the equals sign (=), and then the value in an attribute list.

§Example 3. Sidebar block with an option assigned using the formal syntax
[opts=option]
****
This is a sidebar with an option assigned to it, named option.
****

Separate multiple option values with commas (,).

§Example 4. Sidebar with three options assigned using the formal syntax
[opts="option1,option2"]
****
This is a sidebar with two options assigned to it, option1 and option2.
****

Trait Implementations§

Source§

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

Source§

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

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

const 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§

const 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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.