Expand description
The metadata feature: the document’s metadata (its title, its authors, its date, and
any other key the author writes about the document) and the three pieces that show
the title, the authors and the date before the document’s content.
§What an author writes, and what it produces
The title, the date and each author’s name, affiliations and notes are FLM text,
not plain text: a title may be The \emph{Art} of \(x^2\). An author may have,
beside a name, affiliations, an email address (a plain text) and notes
(MetaAuthor). The author of the document does not write them with commands in
the document’s text; the program that processes the document sets them. The flm
program reads them from the root keys title, author and date of a file’s
front matter (the block of YAML at the top of the file). Each FLM text is parsed as
inline content when the document is processed, and a problem in it is reported at
its place in the file that holds it.
A piece is a document-level synthesized value that a backend places before or
after the document’s content (Piece; see
pieces). The feature builds three pieces,
each placed before the content, and placed by every render unless the render
options leave it out
(PieceDecl::default_on): TITLE
(flm.metadata.title), AUTHOR (flm.metadata.author) and DATE
(flm.metadata.date). On each output:
- on the HTML and rendered-LaTeX outputs, each piece is a block of its own whose
role is its element’s name and whose kind token is
metadata(KIND_METADATA; a<div>on HTML). The title and the date hold one paragraph. The authors hold each author, one after the other, as a group of lines: the name, each affiliation, the email address (a link tomailto:and the address) and each note, each on a line of its own in a span whose role is the part’s element name (rules). The HTML page also uses the words of the title piece as its<title>; - on the plain-text output, each piece is such a block too, with two differences
(
text): the title is in bold, between two rule lines as wide as its widest printed line, and each part of an author after the name is indented by1em(two columns). The date and the authors’ block are as on the other outputs; - on the recomposed LaTeX, each piece is what a LaTeX document passes to
\title,\authorand\date: the title and the date are their content written back as LaTeX; each author is the name,\thanks{…}for each note, then each affiliation and the email address after\\, the authors joined by\and(latex). That backend places a piece only where the render options of thepiecesfeature list it (pieces in the recomposed LaTeX).
A document without metadata places nothing: each piece holds no content. The other
keys of the metadata (DocMeta::other) and of an author (MetaAuthor::other) are
data the library does not show; the program may pass them to the tool it builds the
final output with, such as a template.
§What a program provides
The metadata is an option value of the option type DocMeta, bound per document:
an option type is a plain Rust struct a feature declares once, whose values are set
on a document or on a render request (crate::model::options). A program sets it
on the document it builds
(Doc::with_options). A program that holds
the metadata as data (for example the root keys of a front matter) reads it with
DocMeta::from_data, whose form (data) is the same for every program: title
and date one text each, author one author or a list of authors, an author being
a text (the name) or a map (name, affiliation, email, note). Each text is
kept as the author wrote it, with the place it was written at (MetaText,
MetaPlace). See
the document’s metadata in the
embedding guide.
§What the feature registers
- the option type
DocMeta, bound per document; - the stage
BUILD(flm.metadata.build,BuildMetadata), which parses the title, the authors and the date, numbers the distinct affiliations of the document (AffiliationPayload), and writes the tables of the three pieces. It provides the capabilityREAD(flm.metadata.read), a member of the collectionflm.validatedthat every standard workflow demands, so that checking a document reports the problems the parse of its metadata finds. A problem found only when a piece is lowered for an output, such as a footnote in the title, is reported by a render only; - the three pieces
TITLE,AUTHORandDATE, each a table and a piece declaration contributed to the service slot of thepiecesfeature (pieces::SLOT); - the synthesized elements of the three pieces, of one author (
AUTHOR_ENTRY,flm.metadata.author.entry) and of its parts (AUTHOR_NAME,AUTHOR_AFFILIATION,AUTHOR_EMAIL,AUTHOR_NOTE); no document can write them. Their default lowering rules are inrules, their rules on the recomposed LaTeX inlatex, and their rules on the plain text intext; - the diagnostic
flm.metadata.failed(MetadataFailed), for a part of the metadata that could not be built.
§Interactions with other features
pieces(pieces): the feature contributes its three piece declarations to that feature’s service slot as peer contributions (values for a service slot another feature declares; see services and service slots); without thepiecesfeature no backend places the metadata.- The LaTeX family (
latex): the rules on the recomposed LaTeX are registered with peer declarations of the backend and of the macro construct, so that a registry without the LaTeX features still builds, with those rules set aside (excluded from rule selection; seePeerName). text(text): the rules on the plain text are registered with peer declarations of the backend and of the construct elementflm.pres.text.ruled, in the same way.check(CheckWorkflow): the capabilityREADjoins the collectionflm.validated.
§Items
- The feature:
Metadata,feature,FEATURE. - The metadata:
DocMeta,MetaAuthor,MetaText,MetaPlace; written as data:data,DocMeta::from_data,metadata_schema,TITLE_KEY,AUTHOR_KEY,DATE_KEY,NAME_KEY,AFFILIATION_KEY,EMAIL_KEY,NOTE_KEY,MetaPath,MetaStep,MetaDataError. - The pieces and their elements:
TITLE,AUTHOR,AUTHOR_ENTRY,AUTHOR_NAME,AUTHOR_AFFILIATION,AUTHOR_EMAIL,AUTHOR_NOTE,DATE,KIND_METADATA; the payloadsAffiliationPayloadandEmailPayload. - The stage:
BUILD,READ,BuildMetadata,MetadataFailed. - The lowering rules:
rules(MetaTextRule,AuthorRule,EntryRule,PartRule,EmailRule),latexandtext(TitleTextRule,EntryTextRule). - The style identifier
STYLE(stylesheet), which the general rules require at every piece they stage, and thelatex-rendereddefinition piece delivering it,latex_rendered.
Re-exports§
pub use build::BuildMetadata;pub use build::MetadataFailed;pub use data::AFFILIATION_KEY;pub use data::AUTHOR_KEY;pub use data::DATE_KEY;pub use data::EMAIL_KEY;pub use data::MetaDataError;pub use data::MetaPath;pub use data::MetaStep;pub use data::NAME_KEY;pub use data::NOTE_KEY;pub use data::TITLE_KEY;pub use data::metadata_schema;pub use rules::AuthorRule;pub use rules::EmailRule;pub use rules::EntryRule;pub use rules::MetaTextRule;pub use rules::PartRule;pub use text::EntryTextRule;pub use text::TitleTextRule;
Modules§
- build
- The stage
BuildMetadata(flm.metadata.build), which parses the document’s metadata and builds the three pieces of themetadatafeature, and the diagnosticMetadataFailedit reports when a part of the metadata cannot be built. - data
- The metadata written as data: how a program that holds the author’s metadata as a
map of data values (for example the root keys of a front matter) makes the
document’s
DocMetafrom it, withDocMeta::from_data. - latex
- The lowering rules of the metadata’s pieces on the
latex-recomposedbackend: the title, the authors and the date written back as the LaTeX text that a LaTeX document passes to\title,\authorand\date. - latex_
rendered - The definition piece of the
metadatafeature on thelatex-renderedbackend,flm.latex.def.flmx.metadata(piece). - rules
- The synthesized elements of the metadata’s pieces, and their default lowering
rules. Every backend uses these rules, except that the
latex-recomposedbackend has rules of its own for each of them (latex), and thetextbackend has rules of its own for the title and for one author (text). - text
- The lowering rules of the metadata’s pieces on the
textbackend: the title set between two rule lines, and each author’s parts under the name.
Structs§
- Affiliation
Payload - The payload of an
AUTHOR_AFFILIATIONnode: the affiliation’s number. - DocMeta
- The document’s metadata: the option type the
metadatafeature declares, bound per document (see the module documentation). A program sets its value on the document (Doc::with_options), or reads it from data withDocMeta::from_data. - Email
Payload - The payload of an
AUTHOR_EMAILnode: the address, as the author wrote it. - Meta
Author - One author of the document: the name, the affiliations, the email address, the notes, and every other key the author’s entry holds. Each text keeps the place it was written at, so that a problem in an affiliation is reported at the affiliation.
- Meta
Place - Where a text of the metadata begins: the file, the line and the column, the line and the column counted from 1.
- Meta
Text - A text of the metadata as the author wrote it, and where it was written. The
stage
BUILDparses it as inline FLM content, except an author’s email address (MetaAuthor::email), which is a plain text. - Metadata
- The
metadatafeature: the option typeDocMeta, the stageBUILD, the three pieces and their elements and lowering rules (see the module documentation).
Constants§
- AUTHOR
- The name of the authors piece,
flm.metadata.author. It is also the name of the piece’s table and of the synthesized element at the root of the piece’s content, which holds oneAUTHOR_ENTRYnode per author. - AUTHOR_
AFFILIATION - The name of the synthesized element of one affiliation of an author,
flm.metadata.author.affiliation: it holds the affiliation as inline content, and carries the affiliation’s number (AffiliationPayload). - AUTHOR_
EMAIL - The name of the synthesized element of an author’s email address,
flm.metadata.author.email: it holds no content, and carries the address (EmailPayload). - AUTHOR_
ENTRY - The name of the synthesized element of one author in the authors piece,
flm.metadata.author.entry. It holds the author’s parts, in this order: oneAUTHOR_NAMEnode, oneAUTHOR_AFFILIATIONnode per affiliation, oneAUTHOR_EMAILnode when the author has an email address, and oneAUTHOR_NOTEnode per note. - AUTHOR_
NAME - The name of the synthesized element of an author’s name,
flm.metadata.author.name: it holds the name as inline content. - AUTHOR_
NOTE - The name of the synthesized element of one note about an author,
flm.metadata.author.note: it holds the note as inline content. - BUILD
- The name of the stage that parses the metadata and builds the three pieces,
flm.metadata.build(BuildMetadata). - DATE
- The name of the date piece,
flm.metadata.date. It is also the name of the piece’s table and of the synthesized element at the root of the piece’s content. - FEATURE
- The feature’s registered name,
metadata. - KIND_
METADATA - The kind token that the blocks staged by the rules of the three pieces carry,
metadata: a stylesheet or a program’s lowering rule can select on it (seepres::payload). - READ
- The name of the capability
flm.metadata.read: the document’s metadata has been parsed, and every problem the parse found has been reported. It is a member of the collectionflm.validated, so every standard workflow runs the stageBUILD. - STYLE
- The feature’s style identifier,
flm.metadata.style, which the general rules (MetaTextRule,AuthorRule) require at every piece they stage. On thehtmlbackend it names the feature’s stylesheet (stylesheet); on thelatex-renderedbackend the feature’s definition piece (latex_rendered::piece) delivers it. - TITLE
- The name of the title piece,
flm.metadata.title. It is also the name of the piece’s table and of the synthesized element at the root of the piece’s content.
Functions§
- feature
- Returns the
Metadatafeature, ready to be listed in a package entry. - stylesheet
- The style definition
STYLEon thehtmlbackend: one cascade layer that sets the title large and bold, and the authors and the date indented under the title, the authors one below the other, an author’s affiliations, email address and notes smaller than the name; the sizes, the indentation and the spaces are custom properties it declares (--flm-metadata-title-size,--flm-metadata-line-indent,--flm-metadata-author-detail-size, …). It selects on the blocks and spans the general rules stage (their role and the kind tokenKIND_METADATA), so it applies whatever compose template places the pieces. It sets no rule between the pieces and the content: that belongs to the page that places them.