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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
//! The `text` feature: it registers the text backend, its two construct
//! elements, its native element set, its stages and tables, its render
//! options, the `text` output and the `text` workflow.
//!
//! A feature ([`FlmFeature`]) contributes a related bundle of things to a
//! registry. The `text` feature ([`TextBackend`], obtained as a shared value
//! from [`feature()`]) registers next to the `lowering` feature
//! ([`LoweringFeature`](crate::stdlib::backends::lowering::LoweringFeature)),
//! which registers the presentation vocabulary and the shared lowering rules,
//! and next to the `pieces` and `check` features; [`feature()`] lists what each
//! of them provides to this one.
//!
//! # The elements the backend writes natively
//!
//! The backend's native set ([`native_elements`]) is the whole [presentation
//! vocabulary](crate::stdlib::backends::pres), the two [construct
//! elements](super::construct) of the text backend,
//! [`flm.pres.text.flush-right`](super::construct::FLUSH_RIGHT) and
//! [`flm.pres.text.ruled`](super::construct::RULED), which this feature
//! registers, and the six [structural
//! elements](crate::lang::structural::StructuralElements) of [`FLOW_THROUGH`],
//! whose meaning plain text does not need to translate: `flm.text`,
//! `flm.group`, `flm.opaque-wrapper`, `flm.comment`, `flm.container` and
//! `flm.parbreak`. The
//! paragraph-break element `flm.parbreak` is in that list because the
//! block-structure pass carries an [opaque
//! region](crate::guide::concepts_overview#opaque-regions), such as
//! mathematics, over unchanged and leaves the paragraph breaks inside it in
//! place. The emitter treats it as a
//! separation between blocks in a run of blocks (including the top level of a
//! tree that no block-structure pass has gone over), and as a space inside
//! inline content.
//!
//! The native set holds no element of another feature. Each feature registers
//! lowering rules for its own elements, and the backend writes only the
//! presentation elements those rules produce, so the backend never decides
//! from outside a feature how that feature's content is printed. The
//! `math-passthrough` feature, for instance, lowers its own fallback element
//! into a `flm.pres.math-passthrough` node holding the original source.
//!
//! # What the `text` workflow demands
//!
//! The `text` [workflow](crate::core::registry::WorkflowDef) lists the `text`
//! output and demands one capability beside it:
//! [`flm.validated`](crate::stdlib::VALIDATED), a capability whose demand
//! schedules every check the registry holds. A render of the `text` workflow
//! therefore validates the document: a refused label type, a duplicate label
//! or an error in mathematics content is reported exactly as by the [`check`
//! workflow](crate::stdlib::CHECK_WORKFLOW), so a document gets the same
//! diagnostics regardless of the workflow run over it. The capability
//! `flm.validated` is declared by the `check` feature
//! ([`check_feature`](crate::stdlib::check_feature)), so a registry offering
//! this backend must hold that feature too; a registry without it fails to
//! build, with an error that gives this workflow and the undeclared
//! capability.
//!
//! Everything else the run needs follows from what the selected stages and
//! lowering rules require, not from a list of demands: for instance, the
//! lowering rule for paragraphs requires the capability
//! `flm.blocks.structured`, which puts the block-structure rewrite into the
//! plan.
use Arc;
use crateRegionsOutput;
use crateSettingsDecl;
use crateREGIONS_SLOT;
use crateElementName;
use crateBind;
use crate;
use cratestructural;
use crateVALIDATED;
use crate;
use crate;
use cratepres;
use construct;
use TEXT_OUTPUT;
use ;
/// The feature's registered name, `text`. It is also the middle part of the
/// identifiers of the conditions this backend reports (`flm.text.*`).
pub const FEATURE_NAME: &str = "text";
/// The declaration of the feature's settings: the fields of
/// [`TextRenderOptions`] are its settings keys, bound to the render request
/// ([`Bind::Render`]). See [`crate::core::settings`].
/// The six [structural elements](crate::lang::structural::StructuralElements)
/// the text backend writes natively, beside the presentation vocabulary:
/// `flm.text`, `flm.group`, `flm.opaque-wrapper`, `flm.comment`,
/// `flm.container` and `flm.parbreak` (see the module documentation).
pub const FLOW_THROUGH: = ;
/// Returns the backend's native element set, the elements its emitter writes
/// without a lowering rule: every element of the presentation vocabulary
/// ([`pres::ALL`]), the two construct elements ([`construct::ALL`]), then the
/// elements of [`FLOW_THROUGH`], in that order.
///
/// # Examples
///
/// ```
/// use flm_core::stdlib::backends::pres;
/// use flm_core::stdlib::backends::text::{FLOW_THROUGH, construct, native_elements};
///
/// let native = native_elements();
/// assert_eq!(native.len(), pres::ALL.len() + construct::ALL.len() + FLOW_THROUGH.len());
/// assert!(native.iter().any(|element| element.as_str() == pres::PAR));
/// assert!(native.iter().any(|element| element.as_str() == construct::RULED));
/// ```
/// The `text` feature, which registers the text backend (see the module
/// documentation).
///
/// [`feature()`] returns it as a shared value that a package entry can list.
/// It registers: the construct elements `flm.pres.text.flush-right` and
/// `flm.pres.text.ruled` ([`construct::register`]); the lowered-trees table
/// `flm.lowered.text` that the lowering stage writes; the pieces stage
/// ([`PiecesStage`] for `text`) and the lowered-pieces table
/// `flm.lowered.text.pieces` it writes; the regions stage
/// ([`TextRegionsStage`]) and its table `flm.output.text.regions`, together
/// with the [`RegionsOutput`] that describes the `text` output's regions to a
/// host (contributed to the service slot `flm.output.regions`); the output
/// tables `flm.output.text` and `flm.output.text.document`; the settings of
/// [`TextRenderOptions`]; the backend with its lowering, emit and final stages;
/// the `text` output; and the `text` workflow.
;
/// Returns the `text` feature ([`TextBackend`]) as a shared value, ready to be
/// listed in a package entry.
///
/// A registry holding it must also hold three other features:
///
/// - the `lowering` feature
/// ([`LoweringFeature`](crate::stdlib::backends::lowering::LoweringFeature)),
/// which registers the presentation vocabulary this backend writes
/// natively; without it, the registry fails to build, because the
/// backend's native elements are not declared;
/// - the `pieces` feature
/// ([`pieces::feature`](crate::stdlib::backends::pieces::feature())), which
/// declares the render options the pieces stage reads; without it, every
/// plan of this backend fails;
/// - the `check` feature ([`check_feature`](crate::stdlib::check_feature)),
/// which declares the capability
/// [`flm.validated`](crate::stdlib::VALIDATED) that the `text` workflow
/// demands; without it, the registry fails
/// to build.
///
/// The standard features ([`stdlib::add_features`](crate::stdlib::add_features))
/// include all four.
///
/// # Examples
///
/// ```
/// use flm_core::stdlib::backends::text;
///
/// assert_eq!(text::feature().info().name.as_str(), text::FEATURE_NAME);
/// ```