Expand description
The quote feature: quotations, blocks set apart from the running text
whose content is organized in quotation sections (a quoted passage, lines
set as written, an attribution, ordinary paragraphs). The feature declares
the quote environments quote, blockquote and address by default, and
any other quote environment a host configures.
§What an author writes
A quote environment is an environment whose content is a quotation. The content is made of quotation sections, each written with a quotation-section command:
\text{…}— a quoted passage, one paragraph;\lines{…}— lines set as written, such as a poem or an address: each\\ends a line, and each\indentat the start of a line indents that line by one tab, a unit of indentation whose width each backend decides (Length);\attributed{…}— the attribution: an author or a source;\block{…}— ordinary paragraphs and blocks, lists included.
\begin{quote} To be or not to be.
\text{To be or not to be.}
\attributed{Shakespeare} Shakespeare
\end{quote}
\begin{address} 123 Main St
123 Main St\\ City, ST 12345
City, ST 12345
\end{address}The right column is what the text backend prints. Content written in the
body of a quote environment outside any quotation-section command is the
environment’s bare content. The configuration of each environment
(QuoteEnvironment) states which quotation-section commands its body
accepts, and which kind of quotation section its bare content is read as,
if any; where it states none, bare content is an error. The default
configuration (QuoteConfig) declares three environments:
quoteaccepts the four quotation-section commands and reads no bare content;blockquoteaccepts no quotation-section command and reads its content as one block section;addressaccepts no quotation-section command and reads its content as one lines section.
A host declares other environments with any combination.
A quotation-section command can be written only in text mode, and only
inside the body of a quote environment that accepts it: the commands of an
environment are declared in a scoped package
(ScopedPackageDef) of that
environment, a set of element declarations that can be written only inside
the environment bodies and arguments whose declarations refer to the
package (scoped packages).
Inside a formula, \text{…} is therefore mathematics’ own text command,
never a quotation section. The guide for authors describes quotations
under Quotations.
§What the feature provides to the pipeline
Elements. Every quote environment is one element value of the element
type QUOTE (flm.quote), carrying a QuoteElement. It is a block,
takes no argument, and is declared in text mode. Its body is laid out as
paragraphs and blocks, or as inline content where its bare content is read
as a passage, lines or an attribution
(QuoteEnvironment::holds_blocks). The four quotation-section commands
are four element values of the element type SECTION
(flm.quote.section), each carrying a SectionElement; each is a macro
with one mandatory argument, CONTENT_ARG. A quotation-section command
is in section position when it is written directly in the body of a
quote environment that accepts it. There it opens a quotation section, and
where the body is laid out as paragraphs and blocks, it is a block of its
own between the others. Anywhere else it is inline content.
Scoped packages. The feature declares one scoped package per quote
environment that accepts at least one quotation-section command, whose
name sections_package returns (flm.quote.sections.quote for
quote), holding exactly the commands that environment accepts. It also declares
the scoped package LINES_PACKAGE (flm.quote.lines), which holds
\\ and \indent, the two commands of a lines section. Both are field
macros, macros that carry data rather than content
(fields):
they write nothing of their own, and the lowering rules read them in place
among the line’s content. The argument of \lines and the body of an
environment whose bare content is lines refer to the package.
Reading a quotation’s body. The rules below read the body’s direct children in order. A quotation-section command in section position opens a quotation section. Each maximal run of other content between two quotation sections, without the whitespace and source comments at its edges, is one bare run: it is lowered exactly as a quotation section of the environment’s bare-content kind would be lowered over the same content. The rules read the body each time they lower a quotation, and store nothing.
Lowering rules. A lowering rule (LoweringRule) says how an element
becomes output on a backend. The feature registers these rules. A rule
marked as the default for one backend ranks above a rule marked as the
default everywhere (DefaultMark):
QUOTE_RULE(QuoteRule), the default on every backend that has no rule of its own for a quotation: it stages (builds into the lowered tree;Lowerer) oneflm.pres.blockof roleQUOTE_ROLE(flm.quote), whose one kind token is the environment’s name, holding oneflm.pres.blockper quotation section in the order written, of the role of the section’s kind (TEXT_ROLE,LINES_ROLE,ATTRIBUTED_ROLEorBLOCK_ROLE). A role is a feature-owned dotted name on a presentation payload that says what a container is, and kind tokens classify it further (payload). A passage and an attribution hold one paragraph, a block section holds its paragraphs and blocks, and a lines section holds oneflm.pres.lineswith oneflm.pres.lineper line, the line’s left indentation aLengthof as many tabs as the line has leading\indents. Every quote environment has the same role, so that a stylesheet or a lowering rule treats them alike; the kind token selects one environment. The text backend uses this rule: it prints a quotation as its quotation sections, one blank line apart, with no prefix and no indentation of the whole.SECTION_RULE(SectionRule), the default on every backend that has no rule of its own for a quotation-section command: a quotation-section command outside section position is lowered as its argument’s content.- On the
htmlbackend, the feature’s stylesheetflm.quote.style(html), whichQuoteRulerequires at every quotation. The HTML backend writes the quotation as a<blockquote>and each quotation section as a<div>. - On the
latex-renderedbackend, the definition pieceflm.latex.def.flmx.quote(latex_rendered), which the same requirement brings into the style file. latex::LATEX_RULE(latex::QuoteLatexRule), the default on thelatex-recomposedbackend: it writes the environment as the author wrote it, each quotation section through a LaTeX hook (\flmQuoteText,\flmQuoteLines,\flmQuoteAttributed,\flmQuoteBlock) and a line’s indentation through\flmIndent; the feature’s definition pieceflm.latex.def.quotedefines them in the style file (latex).
Settings. The feature’s configuration, QuoteConfig, is the value
the feature is constructed from; it is fixed when the registry is built
(configuration),
because the environments and their commands are part of the language. The
same value written as data is the feature’s settings: the settings key
environments maps each environment’s name to its QuoteEnvironment,
and a host that combines several sources of settings combines that map
one environment at a time
(SettingsDecl::merge_entries).
The feature feeds the configuration into the registry
digest, the number that changes whenever something
about the registry that can change what processing produces changes
(FeatureBuilder::digest_input); QuoteConfig::digest_bytes gives the
bytes. It declares no option type.
§Errors
The feature reports three conditions
(diagnostics), each an Error, while a quotation is
lowered, on every backend; diagnostics gives each one’s recovery, the
way the lowering goes on after it
(recovery):
BareContent(flm.quote.bare-content) — bare content in an environment that reads none, such as text written directly inquote; reported once per bare run;NestedSection(flm.quote.nested-section) — a quotation-section command written anywhere other than directly in the body of a quote environment, such as inside another quotation section’s argument (\lines{\text{x}});IndentMidLine(flm.quote.indent-mid-line) — an\indentafter the first content of its line.
A quotation-section command that an environment does not accept is not declared in that environment’s body, so writing one there is an unknown command, part of the bare content. One case differs. Inside a quotation nested in a quotation section of another quotation, the enclosing quotation’s commands can still be written, because the scoped packages of the enclosing bodies remain available. Such a command, written directly in the nested body that does not accept it, is part of the nested body’s bare content: where the nested environment reads no bare content, it is reported with its bare run, and it is shown as its argument’s content.
§Interactions with other features
- Block structure. The block role of a quotation-section command is
decided per occurrence (
SectionElement), and the block-structure pass (blocks) lays the body out from it. - Lists. The environment’s name becomes a kind token of the
quotation’s block, so it may not be one of the kind tokens a
presentation list reserves
(
LIST_RESERVED_KINDS);QuoteConfig::validaterefuses such a name. - Other features’ environments. An environment name that another
feature also declares, such as
itemize, makes the registry build fail, as any two declarations of one name do. - Margin notes on the page. The feature’s stylesheet sets
--flm-margin-note-inseton a quotation, so that a note shown in the margin and written inside the quotation still reaches the page’s column of notes (html). - The LaTeX family. The rule of the
latex-recomposedbackend (latex::QuoteLatexRule) uses the LaTeX hooks and definition pieces of the LaTeX family, the code shared by the LaTeX backends, and writes a line’s indentation with the family’s length\flmTabWidth(latex). - The standard features. The standard features
include the feature under the configuration
StdlibConfig::quote.
§Items
Quoteandfeature— the feature, under a configuration or the default one.QuoteConfig,QuoteEnvironment,QuoteSection— the configuration: the environments, what each accepts, the four kinds of quotation section.QuoteElement,SectionElement— the per-value data of the two element typesQUOTEandSECTION.QuoteRule,SectionRule— the general lowering rules;htmlandlatex— the rules of thehtmlandlatex-recomposedbackends.diagnostics— the three conditions.- The names:
FEATURE,QUOTE,SECTION,CONTENT_ARG,LINES_PACKAGE,SECTIONS_PACKAGE_PREFIXandsections_package,LINEBREAK_COMMAND,INDENT_COMMAND,QUOTE_RULE,SECTION_RULE, and the rolesQUOTE_ROLE,TEXT_ROLE,LINES_ROLE,ATTRIBUTED_ROLE,BLOCK_ROLE.
Re-exports§
pub use diagnostics::BareContent;pub use diagnostics::IndentMidLine;pub use diagnostics::NestedSection;
Modules§
- diagnostics
- This module defines the diagnostic conditions that the
quotefeature reports (see diagnostics). All three conditions are errors in the source of a quotation. - html
- The stylesheet of the
quotefeature on thehtmlbackend,flm.quote.style(stylesheet), and the markup it selects on. - latex
- The recomposition rule of the
quotefeature on thelatex-recomposedbackend: a quotation is written back as the environment the author wrote, each quotation section through a LaTeX hook. A LaTeX hook is a macro that the recomposed LaTeX writes and the style file defines with a plain default, which a user redefines in the document’s preamble to change what the recomposed LaTeX does at that point (LaTeX hooks). - latex_
rendered - The definition piece of the
quotefeature on thelatex-renderedbackend,flm.latex.def.flmx.quote(piece).
Structs§
- Quote
- The
quotefeature (FlmFeature), constructed from aQuoteConfig: it registers the quote environments, their quotation-section commands and the lowering rules of a quotation. See the module documentation. - Quote
Config - The configuration of the
Quotefeature: the quote environments, each environment’s name mapped to itsQuoteEnvironment. - Quote
Element - The data that each element value of
QUOTEcarries: which quote environment the value is, and what the configuration declares about it. - Quote
Environment - One quote environment: the quotation-section commands its body accepts, and the kind of quotation section its bare content (content written in the body outside any quotation-section command) is read as.
- Quote
Rule - The implementation of the lowering rule
QUOTE_RULE, the default on every backend: a quotation lowers to oneflm.pres.blockof roleQUOTE_ROLEwhose one kind token is the environment’s name, holding oneflm.pres.blockper quotation section in the order written, of the role of the section’s kind (QuoteSection::role): - Section
Element - The data that each element value of
SECTIONcarries: which quotation-section command the value is. - Section
Rule - The implementation of the lowering rule
SECTION_RULE, the default on every backend: a quotation-section command outside section position is lowered as its argument’s content, with a lines section’s\\and\indentleft out. (A command in section position never reaches this rule: the lowering rule of its quotation stages its quotation section and does not lower the command node itself.)
Enums§
- Quote
Section - The kind of one quotation section of a quote environment, and the quotation-section command that writes it.
Constants§
- ATTRIBUTED_
ROLE - The role of the block an attribution is staged as,
flm.quote.attributed. - BLOCK_
ROLE - The role of the block a block section is staged as,
flm.quote.block. - CONTENT_
ARG - The name of the one argument of a quotation-section command,
content: the content of the quotation section. - FEATURE
- The feature’s registered name,
quote. - INDENT_
COMMAND - The name of the field macro that indents a line of a lines section by one
tab,
indent. - LINEBREAK_
COMMAND - The name of the field macro that ends a line of a lines section: a single
backslash, the name written after the escape character, so that an author
writes
\\. - LINES_
PACKAGE - The name of the scoped package holding the two commands of a lines
section,
\\and\indent:flm.quote.lines. Both are field macros: they write nothing, and the lowering rules read them in place (fields). The declaration of the argument of\linesrefers to it, and so does the declaration of the body of an environment whose bare content is read as lines. - LINES_
ROLE - The role of the block a lines section is staged as,
flm.quote.lines. - QUOTE
- The element type shared by every quote environment,
flm.quote. Each configured environment is one element value of this type, carrying aQuoteElement. - QUOTE_
ROLE - The role of the block a quotation is staged as,
flm.quote, for every quote environment; the environment’s name is the block’s kind token. - QUOTE_
RULE - The name of the general lowering rule of a quotation,
flm.quote.lower.default(QuoteRule), the default on every backend. - SECTION
- The element type shared by the four quotation-section commands,
flm.quote.section. Each command is one element value of this type, carrying aSectionElement. - SECTIONS_
PACKAGE_ PREFIX - The prefix of the name of the scoped package holding the
quotation-section commands of one quote environment,
flm.quote.sections.: the package ofquoteisflm.quote.sections.quote(sections_package). - SECTION_
RULE - The name of the lowering rule of a quotation-section command outside
section position,
flm.quote.section.lower.default(SectionRule), the default on every backend. - TEXT_
ROLE - The role of the block a text section (a quoted passage) is staged as,
flm.quote.text.
Functions§
- feature
- Returns the
Quotefeature under the default configuration (the environmentsquote,blockquoteandaddress), ready to be listed in a package entry. - sections_
package - Returns the name of the scoped package holding the quotation-section
commands that the quote environment
environmentaccepts:SECTIONS_PACKAGE_PREFIXfollowed by the environment’s name.