pub struct Author { /* private fields */ }Expand description
Represents a single author as (typically) described on the author line.
The attributes firstname, middlename, lastname, and authorinitials
are automatically derived from the full value of the author string. When
assigned implicitly via the author line, the value includes all of the
characters and words prior to the semicolon (;), angle bracket (<), or
the end of the line. Note that when using the implicit author line, the full
name can have a maximum of three space-separated names. If it has more, then
the full name is assigned to the firstname attribute. You can adjoin names
using an underscore (_) character.
§Rendered versus raw values
The name, firstname, middlename, lastname, and email
accessors return the value that populates the corresponding document
attribute (author, firstname, …). As in Asciidoctor, that value has the
header substitution group applied – so a literal <, >, or & written on
the author line is escaped (<, >, &), matching what
{author} and the rendered byline emit and what Asciidoctor’s own
doc.author / authors[0].name return.
Each accessor has a raw_ counterpart (raw_name, raw_firstname,
raw_middlename, raw_lastname, raw_email) that returns the same
value before that escaping – attribute references still resolved, but the
literal special characters left as they were written. This mirrors
Asciidoctor’s internal, pre-substitution metadata hash and lets a consumer
that escapes for HTML itself do so exactly once, rather than double-escaping
an already-escaped value.
Implementations§
Source§impl Author
impl Author
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Returns the full name of the author.
The name includes the entire author declaration except for email.
Sourcepub fn firstname(&self) -> &str
pub fn firstname(&self) -> &str
Returns the first, forename, or given name of the author.
The first space-separated name in the value of the author attribute is
automatically assigned to firstname.
Sourcepub fn middlename(&self) -> Option<&str>
pub fn middlename(&self) -> Option<&str>
Returns the middle name or initial of the author.
If author contains three space-separated names, the second name is
assigned to the middlename attribute.
Sourcepub fn lastname(&self) -> Option<&str>
pub fn lastname(&self) -> Option<&str>
Returns the last, surname, or family name of the author.
If the author name contains two or three space-separated names, the last
of those names is assigned to the lastname attribute.
Sourcepub fn email(&self) -> Option<&str>
pub fn email(&self) -> Option<&str>
Returns the email address or URL associated with the author.
When assigned via the author line, it’s enclosed in a pair of angle
brackets (< >). A URL can be used in place of the email address.
Sourcepub fn raw_name(&self) -> &str
pub fn raw_name(&self) -> &str
Returns the full name of the author before the header substitution group escapes any literal special characters.
This is name with attribute references resolved but any
literal <, >, or & written on the author line left unescaped,
mirroring Asciidoctor’s internal metadata hash. Use it when the value
will be HTML-escaped downstream, so the escaping happens exactly once.
Sourcepub fn raw_firstname(&self) -> &str
pub fn raw_firstname(&self) -> &str
Sourcepub fn raw_middlename(&self) -> Option<&str>
pub fn raw_middlename(&self) -> Option<&str>
Returns the middle name of the author before the header substitution group escapes any literal special characters.
See raw_name for how the raw value differs from
middlename.
Sourcepub fn raw_lastname(&self) -> Option<&str>
pub fn raw_lastname(&self) -> Option<&str>
Sourcepub fn initials(&self) -> String
pub fn initials(&self) -> String
Returns the initials of the author.
The first character of the firstname, middlename, and lastname
attribute values are assigned to the authorinitials attribute. The
value of the authorinitials attribute will consist of three characters
or less depending on how many parts are in the author’s name.