Skip to main content

Module metadata

Module metadata 

Source
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 to mailto: 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 by 1em (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, \author and \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 the pieces feature 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 capability READ (flm.metadata.read), a member of the collection flm.validated that 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, AUTHOR and DATE, each a table and a piece declaration contributed to the service slot of the pieces feature (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 in rules, their rules on the recomposed LaTeX in latex, and their rules on the plain text in text;
  • 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 the pieces feature 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; see PeerName).
  • text (text): the rules on the plain text are registered with peer declarations of the backend and of the construct element flm.pres.text.ruled, in the same way.
  • check (CheckWorkflow): the capability READ joins the collection flm.validated.

§Items

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 the metadata feature, and the diagnostic MetadataFailed it 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 DocMeta from it, with DocMeta::from_data.
latex
The lowering rules of the metadata’s pieces on the latex-recomposed backend: the title, the authors and the date written back as the LaTeX text that a LaTeX document passes to \title, \author and \date.
latex_rendered
The definition piece of the metadata feature on the latex-rendered backend, 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-recomposed backend has rules of its own for each of them (latex), and the text backend has rules of its own for the title and for one author (text).
text
The lowering rules of the metadata’s pieces on the text backend: the title set between two rule lines, and each author’s parts under the name.

Structs§

AffiliationPayload
The payload of an AUTHOR_AFFILIATION node: the affiliation’s number.
DocMeta
The document’s metadata: the option type the metadata feature declares, bound per document (see the module documentation). A program sets its value on the document (Doc::with_options), or reads it from data with DocMeta::from_data.
EmailPayload
The payload of an AUTHOR_EMAIL node: the address, as the author wrote it.
MetaAuthor
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.
MetaPlace
Where a text of the metadata begins: the file, the line and the column, the line and the column counted from 1.
MetaText
A text of the metadata as the author wrote it, and where it was written. The stage BUILD parses it as inline FLM content, except an author’s email address (MetaAuthor::email), which is a plain text.
Metadata
The metadata feature: the option type DocMeta, the stage BUILD, 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 one AUTHOR_ENTRY node 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: one AUTHOR_NAME node, one AUTHOR_AFFILIATION node per affiliation, one AUTHOR_EMAIL node when the author has an email address, and one AUTHOR_NOTE node 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 (see pres::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 collection flm.validated, so every standard workflow runs the stage BUILD.
STYLE
The feature’s style identifier, flm.metadata.style, which the general rules (MetaTextRule, AuthorRule) require at every piece they stage. On the html backend it names the feature’s stylesheet (stylesheet); on the latex-rendered backend 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 Metadata feature, ready to be listed in a package entry.
stylesheet
The style definition STYLE on the html backend: 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 token KIND_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.