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 anchor(&'src self) -> Option<&'src str>
pub fn anchor(&'src self) -> Option<&'src str>
Returns the anchor found in this attribute list, if any.
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 (1-based) 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<&'src str>
pub fn id(&'src self) -> Option<&'src str>
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 2Sourcepub fn roles(&'src self) -> Vec<&'src str>
pub fn roles(&'src self) -> Vec<&'src str>
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:
- adds additional semantics to an element
- can be used to apply additional styling to a group of elements (e.g., via a CSS class selector)
- 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).
Sourcepub fn options(&'src self) -> Vec<&'src str>
pub fn options(&'src self) -> Vec<&'src str>
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 prefixing 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.
****Sourcepub fn has_option<N: AsRef<str>>(&'src self, name: N) -> bool
pub fn has_option<N: AsRef<str>>(&'src self, name: N) -> bool
Returns true if this attribute list has the named option.
See options() for a description of option syntax.
Sourcepub fn block_style(&'src self) -> Option<&'src str>
pub fn block_style(&'src self) -> Option<&'src str>
Return the block style name from shorthand syntax.