1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//! The `latex-recomposed` backend: it writes an FLM document back as LaTeX
//! source that stays as close as possible to what the author typed, and leaves
//! numbering, cross-references and every other resolution to LaTeX and to the
//! author's own document class.
//!
//! A backend ([`BackendDef`](crate::core::registry::BackendDef)) is the
//! registration bundle for one output format: the elements its emitter writes
//! natively, a lowering stage, an emit stage and a final stage (see [backends,
//! lowering, and outputs](crate::guide::concepts_overview#backends-lowering-and-outputs)).
//! This module holds the backend for recomposed LaTeX, registered by the
//! [`LatexRecomposed`] feature.
//!
//! # What the backend produces
//!
//! The output is an artifact set
//! ([`ArtifactSet`](crate::core::artifact::ArtifactSet)) of up to two LaTeX
//! files and any files other features add beside them:
//!
//! - the recomposed LaTeX of the document (the entry artifact), and
//! - a **style file**, a `.sty` file written beside it that holds exactly the
//! definitions the recomposed LaTeX needs to compile: LaTeX packages,
//! declarations of non-ASCII characters,
//! [definition pieces](crate::stdlib::backends::latex::LatexPreambleDef)
//! (units of LaTeX definitions that features register), and the document's
//! own [user definitions](crate::lang::rewrites::userdefs::Definition)
//! written as LaTeX definitions (see [`style`](crate::stdlib::backends::latex::style)). The
//! definitions in it are guarded, so that a user can define any of them
//! before the style file is loaded, or redefine it after, in the document's
//! preamble. The exceptions are the definitions that the render option
//! [`bare_names`](LatexRecomposedRenderOptions::bare_names) puts under the
//! document's own names, which are written unconditionally, and the
//! author's own text from
//! [`extra_preamble`](LatexRecomposedRenderOptions::extra_preamble), which
//! is written as given. The file's name is the render option
//! [`style_stem`](LatexRecomposedRenderOptions::style_stem) and a hash of
//! the file's content, to which the host's naming service may add a prefix
//! (`paper-flmrecomposed.1a2b3c4d.sty` for a document written as
//! `paper.tex`); the document loads the file by that name (see
//! [`mod@stages`], "The style file's path").
//!
//! The recomposed LaTeX is written over the *raw* tree: the frozen tree in
//! which no paragraphs were built, no typographic substitution was made, and
//! the author's whitespace and blank lines are kept. Some constructs are
//! written in a fixed form rather than as the author typed them. A use site of
//! a user definition that the backend keeps is written as a call of the
//! definition that the style file holds, so that LaTeX never reads again
//! anything FLM has already read
//! ([`kept`](crate::stdlib::features::userdefs::kept)). With the default
//! render options, headings, labels and references are written through LaTeX
//! hooks ([`preamble`](crate::stdlib::backends::latex::preamble)), with each
//! label replaced by its safe label
//! ([`SafeLabels`](crate::stdlib::features::refs::SafeLabels)); see the
//! render options [`heading_hook`](LatexRecomposedRenderOptions::heading_hook)
//! and [`label_hooks`](LatexRecomposedRenderOptions::label_hooks). The syntax
//! of every call is normalized (see [`mod@emit`]).
//!
//! # Who registers what
//!
//! The [`LatexRecomposed`] feature registers the backend, its two structural
//! [lowering rules](crate::core::lowering::LoweringRule), its stages and
//! tables, the `latex-recomposed` output and the `latex-recomposed` workflow.
//! It relies on three other features: the `latex`
//! feature ([`LatexFamily`](crate::stdlib::backends::latex::LatexFamily)),
//! which registers the LaTeX construct elements
//! ([`construct`](crate::stdlib::backends::latex::construct)) and the service
//! slots through which package requests and definition pieces are resolved,
//! and the `lowering` feature
//! ([`LoweringFeature`](crate::stdlib::backends::lowering::LoweringFeature)),
//! which registers the shared presentation elements, and the `check` feature
//! ([`check_feature`](crate::stdlib::check_feature)), which declares the
//! collection `flm.validated` that the `latex-recomposed` workflow demands.
//!
//! Each content feature (headings, references, mathematics, and so on)
//! registers, in its own `latex` module, the lowering rule that writes its
//! elements back as LaTeX construct elements: its *recomposition rule* (see
//! [`mod@rules`] for how such a rule depends on this backend without the
//! feature depending on it). The emitter writes those construct elements
//! through the LaTeX family's typed sink
//! ([`LatexSink`](crate::stdlib::backends::latex::LatexSink)).
//!
//! # The modules of the backend
//!
//! - [`mod@feature`]: the [`LatexRecomposed`] feature, the native element set
//! ([`native_elements`]) and the render options
//! ([`LatexRecomposedRenderOptions`]).
//! - [`mod@rules`]: the two structural lowering rules (the paragraph break and
//! the paragraph), which require the raw tree.
//! - [`mod@emit`]: the emitter ([`emit_tree`]), what each lowered node writes,
//! and the conditions (the kinds of diagnostic it reports; see
//! [diagnostics](crate::guide::concepts_overview#diagnostics))
//! `flm.latex-recomposed.unknown-character`,
//! `flm.latex-recomposed.nesting-too-deep` and
//! `flm.latex-recomposed.worker-thread-unavailable`.
//! - [`mod@stages`]: the emit stage, the regions stage (which writes the
//! placed pieces, assembles the style file and writes the output regions),
//! the final stage, their tables, the artifact set, and the
//! conditions `flm.latex-recomposed.stage-failed`,
//! `flm.latex-recomposed.unknown-requirement`,
//! `flm.latex-recomposed.package-options-conflict` and
//! `flm.latex-recomposed.definition-name-refused`.
//!
//! [The recomposed LaTeX
//! backend](crate::guide::rendering#the-recomposed-latex-backend) section of the
//! rendering guide describes the backend in full: what each construct writes,
//! escaping and the Unicode modes, references and safe labels, mathematics,
//! verbatim content, and the plan a `latex-recomposed` workflow builds.
pub use ;
pub use ;
pub use ;
pub use ;