ElementAttribute

Struct ElementAttribute 

Source
pub struct ElementAttribute<'src> { /* private fields */ }
Expand description

This struct represents a single element attribute.

Element attributes define the built-in and user-defined settings and metadata that can be applied to an individual block element or inline element in a document (including macros). Although the include directive is not technically an element, element attributes can also be defined on an include directive.

Implementations§

Source§

impl<'src> ElementAttribute<'src>

Source

pub fn name(&'src self) -> Option<&'src str>

Return the attribute name, if one was found`.

Source

pub fn shorthand_items(&'src self) -> Vec<&'src str>

Return the shorthand items, if applicable.

Shorthand items are only parsed for certain element attributes. If this attribute is not of the appropriate kind, this will return an empty list.

Source

pub fn block_style(&'src self) -> Option<&'src str>

Return the block style name from shorthand syntax.

Source

pub fn id(&'src self) -> Option<&'src str>

Return the ID attribute from shorthand syntax.

If multiple ID attributes were specified, only the first match is returned. (Multiple IDs are not supported.)

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<&'src str>

Return any role attributes that were found in shorthand syntax.

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<&'src str>

Return any option attributes that were found in shorthand syntax.

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

pub fn value(&'src self) -> &'src str

Return the attribute’s value.

Note that this value will have had special characters and attribute value replacements applied to it.

Trait Implementations§

Source§

impl<'src> Clone for ElementAttribute<'src>

Source§

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

Returns a duplicate 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 ElementAttribute<'src>

Source§

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

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

impl<'src> PartialEq for ElementAttribute<'src>

Source§

fn eq(&self, other: &ElementAttribute<'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 ElementAttribute<'src>

Source§

impl<'src> StructuralPartialEq for ElementAttribute<'src>

Auto Trait Implementations§

§

impl<'src> Freeze for ElementAttribute<'src>

§

impl<'src> RefUnwindSafe for ElementAttribute<'src>

§

impl<'src> Send for ElementAttribute<'src>

§

impl<'src> Sync for ElementAttribute<'src>

§

impl<'src> Unpin for ElementAttribute<'src>

§

impl<'src> UnwindSafe for ElementAttribute<'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.