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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
//! The lowering rules of the [`xnotes`](super) feature for the `html`
//! backend, and the feature's stylesheet.
//!
//! On the HTML page, an xnote and a list of xnotes are written with the same
//! presentation elements as on every other output: the rules of this module
//! call the staging helpers of the general rules
//! ([`stage_mark`](super::stage_mark), [`stage_in_place`](super::stage_in_place),
//! [`ListRule`]), so that the page writes the same structure as the other
//! outputs that use these shapes, and
//! the HTML backend writes those elements as its HTML contract states (the
//! classes and attributes a stylesheet may rely on; see
//! [`CONVENTIONS`](crate::stdlib::backends::html::CONVENTIONS) and [the HTML
//! contract](crate::guide::rendering#the-html-contract)). The rules of this
//! module are marked default on the `html` backend and add what only the page
//! needs:
//!
//! - the **link back** from each entry of a list of xnotes to its mark
//! ([`ListHtmlRule`]);
//! - **no bracket text** around an xnote shown in place ([`XnoteHtmlRule`]):
//! the stylesheet draws the brackets, so that a page's own stylesheet can
//! replace them;
//! - the **stylesheet** [`STYLE`] (`flm.xnotes.style`). The staging helpers
//! that the general rules and these rules share require the feature's
//! style identifier [`STYLE`] at every xnote and every list: they record it
//! as a requirement of the output, and on this backend it names the
//! stylesheet, which the backend then writes or loads (see [`StyleDef`]).
//!
//! # The markup
//!
//! The worked example, `The claim holds in every case.\footnote{Except the
//! empty one, which we exclude by convention.} The next sentence goes on.`,
//! writes the mark as a superscript carrying the mark's anchor (its `id`),
//! around a link to the xnote. The link carries the document role
//! `doc-noteref` and an accessible name (the name that assistive technology
//! reads in place of the link's text), so that a screen reader announces
//! "Footnote 1" rather than "1":
//!
//! ```html
//! <p class="flm-pres-par">The claim holds in every case.<sup class="flm-pres-span flm-xnotes-xnote-mark" id="fnref--1yuhk" data-flm-style="superscript"><a class="flm-pres-link" href="#fn-1" role="doc-noteref" aria-label="Footnote 1" data-flm-kind="xnote">1</a></sup> The next sentence goes on.</p>
//! ```
//!
//! The list of the xnote kind is placed after the document's content: a block
//! of the document role `doc-endnotes` holding the title as a heading and a
//! labeled list whose entries carry the xnotes' anchors. The last paragraph of
//! each entry ends with a link back to the mark, of the role `doc-backlink`,
//! whose text is the kind's [`backlink`](super::XnoteKind::backlink) (`↩`) and
//! whose accessible name is `Back to ` followed by the xnote's name as a
//! reference writes it:
//!
//! ```html
//! <div class="flm-pres-block flm-xnotes-footnote-list" role="doc-endnotes" data-flm-kind="xnotes footnote">
//! <h2 class="flm-pres-block--heading" data-flm-heading="xnotes" data-flm-level="2" data-flm-toc="false">Footnotes</h2>
//! <ol class="flm-pres-list" data-flm-kind="numbered xnotes footnote labeled">
//! <li id="fn-1"><span class="flm-pres-list-label"><sup class="flm-pres-span flm-xnotes-entry-mark" data-flm-style="superscript">1</sup></span>
//! <p class="flm-pres-par">Except the empty one, which we exclude by convention. <a class="flm-pres-link" href="#fnref--1yuhk" role="doc-backlink" aria-label="Back to Footnote 1" data-flm-kind="xnote-back">↩</a></p>
//! </li>
//! </ol>
//! </div>
//! ```
//!
//! The heading is written with the tag of its level, or with the tag to which
//! the render option
//! [`heading_tags`](crate::stdlib::backends::html::HtmlRenderOptions::heading_tags)
//! maps the heading name `xnotes` ([`TITLE_HEADING`](super::TITLE_HEADING)).
//! Where the plan computes no anchors (in a registry without the references
//! feature), the mark has no link and the entry no link back.
//!
//! An xnote of a kind shown **in place** is one span where its content is
//! inline, carrying the xnote's anchor, its kind tokens and the document role
//! `doc-footnote`, with the mark inside it and no link:
//!
//! ```html
//! …every case. <span class="flm-pres-span flm-xnotes-xnote-inplace" id="fn-1" role="doc-footnote" data-flm-kind="xnotes footnote"><sup class="flm-pres-span flm-xnotes-xnote-mark" id="fnref--1yuhk" data-flm-style="superscript">1</sup>Except the empty one, which we exclude by convention.</span> The next…
//! ```
//!
//! Where its content holds paragraphs, it is a block, as a list is: the
//! paragraph it is written in ends before it, the text after it is a new
//! paragraph, and its mark is at the head of its first paragraph:
//!
//! ```html
//! <p class="flm-pres-par">Two paragraphs.</p>
//! <div class="flm-pres-block flm-xnotes-xnote-inplace" id="fn-1" role="doc-footnote" data-flm-kind="xnotes footnote">
//! <p class="flm-pres-par"><sup class="flm-pres-span flm-xnotes-xnote-mark" id="fnref--1yuhk" data-flm-style="superscript">1</sup>First paragraph.</p>
//! <p class="flm-pres-par">Second paragraph.</p>
//! </div>
//! <p class="flm-pres-par">And on.</p>
//! ```
//!
//! The mark of an unnumbered xnote kind is its fixed mark, and an empty fixed
//! mark gives an empty `<sup>`, so that the mark's anchor still exists.
//!
//! # The stylesheet
//!
//! The style definition [`stylesheet`] (`flm.xnotes.style`; see
//! [`StyleDef`]) is one cascade layer holding the line above a list of xnotes,
//! with a space between the line and the list's content, and the brackets
//! around an xnote shown in place, and nothing more. Every
//! value it uses is a custom property declared in it
//! (`--flm-xnotes-list-rule`, `--flm-xnotes-list-size`,
//! `--flm-xnotes-list-space`, `--flm-xnotes-list-padding`,
//! `--flm-xnotes-inplace-open`, `--flm-xnotes-inplace-close`), which a page sets to change these values
//! without writing a rule of its own. The xnote and the list require it, so a
//! page holding no xnote does not carry it.
//!
//! **The feature ships no script.** An xnote shown in place is always written
//! whole, with every anchor, role and kind token as an attribute, so that a
//! page's own stylesheet or script can lay it out, hide it or show it; a
//! script shipped by the feature would interfere with the page's own. A host
//! adds a stylesheet or a script of its own by declaring a style or script
//! definition in a feature of its own
//! ([`FeatureBuilder::style_def`](crate::core::registry::FeatureBuilder::style_def),
//! [`script_def`](crate::core::registry::FeatureBuilder::script_def)) and
//! requiring it from a rule, or replaces the content of this stylesheet
//! through the render option
//! [`definitions`](crate::stdlib::backends::html::HtmlRenderOptions::definitions).
//!
//! # Registration
//!
//! The rules are marked default on the `html` backend only, and are
//! registered under a peer declaration
//! ([`PeerName`](crate::core::registry::PeerName)) of that backend, so that a
//! registry without the backend still builds, with the rules set aside
//! (excluded from rule selection). The `xnotes` feature registers the
//! stylesheet and, where a configured xnote kind has a command, the xnote's
//! rule ([`html_rule`]);
//! [`contribute_kind`](super::contribute_kind) registers the list's rule for
//! each xnote kind, like every rule of a kind's list.
use Arc;
use ;
use crate;
use crate;
use crateFlm;
use crate;
use crateBACKEND;
use crate;
use crateANCHORS;
use XnoteKind;
use ;
use ;
use XnoteRecord;
use ;
/// The name of the lowering rule of an xnote on the `html` backend,
/// `flm.xnotes.xnote.lower.html` ([`XnoteHtmlRule`]).
pub const HTML_RULE: &str = "flm.xnotes.xnote.lower.html";
/// The words with which the accessible name of an entry's link back to its
/// mark begins, before the xnote's name: `Back to`.
pub const BACKLINK_LABEL_PREFIX: &str = "Back to";
/// The name of the lowering rule of the list element of the xnote kind `kind`
/// on the `html` backend, `flm.xnotes.<kind>.list.lower.html`
/// ([`ListHtmlRule`]).
/// The feature's style definition, `flm.xnotes.style` ([`STYLE`]): the line
/// above a list of xnotes and the brackets around an xnote shown in place,
/// in one cascade layer, with every value a custom property it declares. The
/// `xnotes` feature registers it; the xnote and the list require it.
/// See the [module documentation](self).
/// The lowering rule of an xnote on the `html` backend, [`HTML_RULE`]: the
/// xnote's mark, or the xnote in place, as the general rule writes them
/// ([`stage_mark`](super::stage_mark),
/// [`stage_in_place`](super::stage_in_place)), but with no bracket text,
/// because the stylesheet draws the brackets. It requires the style
/// identifier [`STYLE`] and reports the refused content of the optional
/// argument as the general rule does.
;
/// The lowering rule of an xnote kind's list element on the `html` backend
/// ([`list_rule_name`]): the list as the general rule writes it
/// ([`ListRule`]), with the link back to each xnote's mark at the end of the
/// last paragraph of its entry. It requires the style identifier [`STYLE`],
/// as the general rule does.
///
/// The link back is
/// `flm.pres.link { href: "#<the mark's anchor>", kind: xnote-back,
/// doc_role: BackLink, label: "Back to <the xnote's name>" }` holding the
/// kind's [`backlink`](XnoteKind::backlink) text, after a space. The xnote's
/// name is the kind's singular word, as a reference writes it in running text
/// (with no variant), then the xnote's number as a reference writes it
/// without the word (`Back to Footnote 1`); the word alone where there is no
/// number. There is no link back where the mark has no anchor (in a registry
/// without the references feature), for an entry whose pointer refers to no
/// recorded xnote, and for a kind whose `backlink` text is empty.
/// Stages the link back from the entry of the xnote `record` of the xnote
/// kind `kind` to its mark, after a space, as [`ListHtmlRule`] documents it;
/// nothing where there is no link back.
/// The lowering rule of an xnote on the `html` backend, [`HTML_RULE`]
/// ([`XnoteHtmlRule`]), marked default on that backend only.
/// The lowering rule of the list element of the xnote kind `kind` on the
/// `html` backend ([`ListHtmlRule`], [`list_rule_name`]), marked default on
/// that backend only, writing the list as `list` does, with the links back.
/// The default mark of every rule of this module: default on the `html`
/// backend only.
/// Makes a peer declaration of the `html` backend, on behalf of the feature
/// that `b` registers, so that a registry without the backend builds with the
/// rules of this module set aside. Every call declares it: the registry
/// merges an identical repeated peer declaration into the first.
/// Registers what the `xnotes` feature itself contributes to the page: the
/// stylesheet ([`stylesheet`]), and, where the configuration declares an
/// xnote kind with a command (where the element [`XNOTE`] exists), the
/// xnote's rule ([`html_rule`]) under the peer declaration of the backend.
///
/// # Errors
///
/// The [`BuildError`] of the registry builder when a declaration is made
/// in a [registration round](crate::core::registry::builder#the-two-registration-rounds)
/// that does not accept it (from a finalizer, for instance).
pub
/// Declares what the xnote kind `kind` needs on the page, on behalf of the
/// feature that `b` registers: the rule of its list element on the `html`
/// backend, which writes the list as `list` (the kind's general rule) does,
/// under the peer declaration of the backend.
/// [`contribute_kind`](super::contribute_kind) calls it once per kind.
///
/// Only the `xnotes` feature declares the stylesheet the rule requires: where
/// that feature is absent, no list of the kind has entries to write.
///
/// # Errors
///
/// The [`BuildError`] of the registry builder when a declaration is made
/// in a [registration round](crate::core::registry::builder#the-two-registration-rounds)
/// that does not accept it (from a finalizer, for instance).
pub