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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
//! The `lists` feature ([`Lists`]): list environments whose items are begun
//! by `\item`, the label shown beside each item, and references to items. By
//! default the list environments are `itemize`, `enumerate` and
//! `description`.
//!
//! # Lists and list kinds
//!
//! A **list** is an environment whose body is a sequence of items, each begun
//! by `\item`. Each list environment has one **list kind**, which the
//! feature's configuration, [`ListsConfig`], declares under the environment's
//! name: for each list kind, whether its items are numbered and which label is shown beside them
//! at each nesting depth ([`ListKind`]). The default configuration declares
//! three list kinds:
//!
//! ```text
//! \begin{itemize} \begin{enumerate} \begin{description}
//! \item First \item First \item[Term] What it means.
//! \item Second \item Second \item[Other] More.
//! \end{itemize} \end{enumerate} \end{description}
//!
//! • First 1. First Term What it means.
//! • Second 2. Second Other More.
//! ```
//!
//! A list nested in an item of another list of the same list kind is at the
//! next **nesting depth**, and shows the list kind's next label template:
//! `-` then `▸` for `itemize`, `(i)` then `a-` for `enumerate`; the last
//! template serves every deeper list. Only lists of the same list kind are
//! counted: an `enumerate` inside an `itemize` inside an `enumerate` is at
//! depth 2 and shows `(i)`, as in LaTeX. The
//! [language guide](crate::guide::language_syntax#lists) describes lists for
//! authors.
//!
//! # The optional argument of a list
//!
//! Each list environment takes an optional argument, a key-value argument
//! with two keys:
//!
//! - `label` is the list's own **label template**, used beside its items in
//! place of the depth's template. It is written in the language of a
//! counter style's number template: every `#{name}` is the item's number in
//! the number format `name`, and every other character is FLM text written
//! as is.
//! - `ref` is the list's own **reference template**, in the same language:
//! the template through which a reference to one of its items writes the
//! item's number, in place of the depth's reference template. The key is
//! named after the key of LaTeX's `enumitem` package that does the same.
//!
//! `label=` written alone sets both templates to the same text:
//!
//! ```text
//! \begin{enumerate}[label=(#{alph})] % (a), (b); \ref: Item~(b)
//! \begin{enumerate}[label=#{arabic}:, ref=#{arabic}] % 1:, 2:; \ref: Item~2
//! \begin{itemize}[label={--}] % a dash beside every item
//! ```
//!
//! A bracket holding no `=` and made only of the characters `[]().:-+*aAiI1`
//! is a **short form** of `label=`, the syntax of LaTeX's `enumerate`
//! package. With one of the characters `a`, `A`, `i`, `I`, `1`, that
//! character stands for the number in the number format it shows: `[(i)]` is
//! `label=(#{roman})`, `[1.]` is `label=#{arabic}.`, `[a-]` is
//! `label=#{alph}-`. With none of them, the text is a fixed label: `[-]`,
//! `[*]`, `[+]`. A short form that writes a number also sets the reference
//! template: the same text with every full stop, colon and hyphen at its end
//! dropped, so `[1.:]` is `label=#{arabic}.:, ref=#{arabic}` and `[(i)]`
//! refers to its items as `(#{roman})`. A fixed short form refers to its
//! items by its label. Any other text, a Unicode bullet included, is written
//! with `label={…}`; a `]` inside the bracket is protected by braces. A short
//! form holding two of the five characters is an error, since it could mean
//! two things ([`BadLabelForm`]). See [`list_options`], [`short_form`] and
//! [`short_form_ref`].
//!
//! A `ref=` on a list whose list kind is not numbered has no number to
//! write. It is accepted and reported as a Note ([`RefIgnored`]), so that a
//! list can be switched between a numbered and an unnumbered list kind
//! without its bracket being rewritten.
//!
//! # Items
//!
//! Inside a list's body, and nowhere else, `\item` begins an item. `\item`
//! is declared in a scoped package ([`ScopedPackageDef`]), [`PACKAGE`]:
//! a set of element declarations that can be written only inside the bodies
//! and arguments whose declarations refer to the package (see
//! [scoped packages](crate::guide::concepts_overview#scoped-packages)); the
//! body of every list environment refers to it. Everything after an `\item`
//! up to the next one, or to the end of the body, is the item's content,
//! which is block content: paragraphs, nested lists, displayed formulas. An
//! empty item is still an item. Whitespace and comments before the first
//! `\item` are skipped; any other content there is the error
//! [`ContentBeforeItem`].
//!
//! An `\item` takes an optional key-value argument with one key, `tag`: FLM
//! content shown as the item's label in place of the list's template, in a
//! numbered list as in an unnumbered one. A bracket holding no `=` outside
//! braces is the whole tag: `\item[My tag]` is `\item[tag={My tag}]`, and
//! `\item[tag={a=b}]` protects a `=`. See [`item_options`].
//!
//! After an `\item` and its bracket, `\label{item:…}` fields attach labels to
//! the item, several of them if needed, as they do after a heading's title.
//! A label is the text an author writes as `\label{type:label}` after a
//! construct (see
//! [labels](crate::guide::concepts_overview#reference-points-labels-and-anchors));
//! an item accepts the label type `item` only ([`LABEL_TYPES`]).
//!
//! # The label beside an item
//!
//! The label shown beside an item is, in this order: its tag; else the
//! list's own label template; else the label template the list kind declares
//! for the list's depth.
//!
//! - A template that writes a number writes the item's number through that
//! label template, without the word a reference writes before it: `2.`
//! beside the item, `Item~2` in a reference. The numbering feature's stage
//! [`NUMBER`](crate::stdlib::features::numbering::NUMBER), which records
//! each reference point's counter value in the counter table, records each
//! item's number with the counter style of the list's depth, whose number
//! format is the list's reference template. To write the label, the list's
//! rule takes that counter style, replaces its number format by the label
//! template
//! ([`CounterStyle::with_number_format`](crate::stdlib::features::numbering::CounterStyle::with_number_format)),
//! and compiles the result once per list when the list is lowered.
//! - A template that writes no number is a fixed label, shown beside every
//! item.
//! - A list of a list kind that declares no template (`description`) writes
//! no label of its own, and an item there without a tag is the error
//! [`MissingTag`].
//!
//! A fixed template on a numbered list (`\begin{enumerate}[label={*}]`)
//! shows `*` beside every item. Every item is still counted and has its
//! number, which a reference writes through the same template, `Item~*`,
//! since `label=` alone sets the reference template too. An explicit empty
//! `label={}` shows no label at all. Whether a list is numbered depends on
//! its list kind, never on its template: a template that writes a number on
//! an unnumbered list is the error [`LabelNamesNumber`], and the depth's
//! template is used instead.
//!
//! # Numbers
//!
//! The items of a numbered list kind are numbered by the
//! [`numbering`](crate::stdlib::features::numbering) feature, and by nothing
//! else. Each numbered list kind declares a counter
//! ([`CounterDecl`](crate::stdlib::features::numbering::CounterDecl)) and
//! one counter style
//! ([`CounterStyleDecl`](crate::stdlib::features::numbering::CounterStyleDecl))
//! per depth, whose number format is the depth's reference template
//! ([`numbers`]). Each list environment of the list kind is a scoped instance
//! of the counter (see
//! [scoped instances](crate::model::aspects::NumberSource#scoped-instances)
//! and, for authors, the
//! [numbering guide](crate::guide::numbering#scoped-instances)), so that
//! each list numbers its own items from one, a list nested in a numbered item
//! of another list is counted within that item, and the enclosing list
//! continues after it.
//!
//! An item carrying a tag is counted in no counter and has no number:
//! `\item[Custom] \item \item` shows `Custom`, `1.`, `2.`, as in LaTeX.
//!
//! In a registry without the numbering feature, nothing numbers items. The
//! counters and counter styles are dropped when the registry is built, with
//! one Note for each of the numbering feature's two service slots, and a
//! numbered list whose label writes a number shows
//! no label and is reported once ([`NoNumbering`]); a fixed label and a tag
//! are still shown.
//!
//! # References to items
//!
//! Every `\item` of a list is one reference point: one place in a document
//! that can be referred to, numbered, or given an anchor
//! ([`RefPoint`]; see
//! [reference points](crate::guide::concepts_overview#reference-points-labels-and-anchors)).
//! Its reference kind is `item` ([`KIND`]), and its anchor is derived from
//! its first label or, for an unlabeled item, from its position
//! ([`ANCHOR_PREFIX`]). `\ref{item:x}` shows what is shown beside the item,
//! through the ordinary path of the
//! [references](crate::stdlib::features::refs) feature:
//!
//! - for a numbered item, the word and the number written through the list's
//! reference template: `Item~2`, `Item~(ii)`, and `(ii)` under
//! `\ref[noprefix]`;
//! - for an item carrying a tag, the tag, however it is written
//! (`\item[Custom]`, `tag=Custom`, `tag={Custom}`);
//! - for an untagged item of an unnumbered list, its label: the list's own
//! (`[-]`, `label=*`, `label={--}`) where it writes one that can be used,
//! else the label template the list kind declares for the depth, so that
//! `\ref{item:x}` on an `itemize` item shows `•`.
//!
//! An unnumbered list kind's reference templates, and a `ref=` on its lists,
//! have no effect. [`ItemElement`] describes how the reference point carries
//! that content.
//!
//! # What the feature registers
//!
//! Under a [`ListsConfig`], the feature registers:
//!
//! - one value of the element type [`LIST`] (`flm.lists.list`) per list kind,
//! written as the environment of the list kind's name, carrying a
//! [`ListElement`];
//! - the scoped package [`PACKAGE`] holding `\item`, whose element [`ITEM`]
//! (`flm.lists.item`) carries an [`ItemElement`], the item's reference
//! point;
//! - for each numbered list kind, a counter and its counter styles, as peer
//! contributions to the numbering feature's service slots ([`numbers`]);
//! - peer declarations ([`PeerName`](crate::core::registry::PeerName)) of the
//! numbering feature's counter table and of the references feature's
//! anchors table, which the list rule reads where they exist, and of the
//! references feature's argument role
//! [`DEFINED_LABEL_ARG_ROLE`](crate::stdlib::features::refs::DEFINED_LABEL_ARG_ROLE),
//! the role of the argument of an item's `\label` field;
//! - a build hook ([`LateInit`](crate::core::registry::LateInit)) that
//! compiles every list kind's label templates, and a numbered list kind's
//! reference templates, once the registry's parsing language
//! ([`BuiltLang`](crate::lang::BuiltLang)) is built; a template that does
//! not compile, or a label template of an unnumbered list kind that writes
//! a number format, fails the registry build;
//! - the lowering rules [`RULE`] and [`ITEM_RULE`], and the recomposition
//! rule [`latex::LATEX_RULE`] of the `latex-recomposed` backend;
//! - its settings: the fields of [`ListsConfig`] as data
//! ([`crate::core::settings`]).
//!
//! # How a list is lowered
//!
//! On every backend except `latex-recomposed`, the lowering rule [`RULE`]
//! ([`ListRule`]) lowers a list to one
//! [`flm.pres.list`](crate::stdlib::backends::pres::LIST) node holding, per
//! item, a `label` content slot and an `item` content slot. Its kind tokens
//! are, in this order:
//!
//! - the list kind's structural token:
//! [`LIST_NUMBERED`](crate::stdlib::backends::pres::LIST_NUMBERED) for a
//! numbered list kind,
//! [`LIST_UNNUMBERED`](crate::stdlib::backends::pres::LIST_UNNUMBERED) for
//! an unnumbered list kind that declares label templates,
//! [`LIST_TERMS`](crate::stdlib::backends::pres::LIST_TERMS) for a list
//! kind that declares none;
//! - the environment's name;
//! - [`LIST_LABELED`](crate::stdlib::backends::pres::LIST_LABELED), since
//! every item's label is written as content of the `label` slot.
//!
//! Each item's anchor (the identifier its reference point was given) is
//! carried on the list's payload
//! ([`ListPayload`](crate::stdlib::backends::pres::ListPayload)), one per
//! entry, read from the references feature's anchors table where there is
//! one, so that a link to the item leads to it. A list inside a footnote
//! keeps its items' numbers and anchors where the
//! [`xnotes`](crate::stdlib::features::xnotes) feature gathers the
//! footnotes, because the footnotes are shown there with their own content,
//! not with a copy of it.
//!
//! What each backend makes of the `flm.pres.list` node:
//!
//! - **HTML**: an `<ol>`, `<ul>` or `<dl>` chosen by the structural kind
//! token, as the [HTML contract](crate::stdlib::backends::html::CONVENTIONS)
//! states; the `labeled` kind token switches off the marker the browser
//! would draw.
//! - **Text**: each label followed by the item's blocks, every item's blocks
//! aligned at one column.
//! - **`latex-recomposed`**: the general rule is not used; the recomposition
//! rule [`LATEX_RULE`](latex::LATEX_RULE) writes the list back as its
//! environment and its items as `\item`s ([`latex`]).
//!
//! A list inside a
//! [synthesized value](crate::guide::concepts_overview#synthesized-values)
//! (for example a label template that holds a list) has items that the
//! references feature's stage
//! [`ANCHORS_STAGE`](crate::stdlib::features::refs::ANCHORS_STAGE), which
//! gives each reference point its anchor, and the numbering stage never saw.
//! The list is reported once for each table that holds no entry for those
//! items (`flm.run.missing-entry`), and it is still written, those items
//! without an anchor and without a number.
//!
//! [`ITEM_RULE`] ([`ItemRule`]), the default on every backend, lowers an
//! `\item` that is inside a list but not directly in its body, which begins
//! no item, to nothing, and reports [`ItemOutsideList`].
//!
//! # Interactions with other features
//!
//! - The [`numbering`](crate::stdlib::features::numbering) feature numbers
//! the items of numbered lists; without it, see [Numbers](#numbers).
//! - The [`refs`] feature checks the labels,
//! computes the anchors and resolves `\ref`; without it, no item has an
//! anchor, and nothing is reported.
//! - The [`refpoints`](crate::stdlib::features::refpoints) feature collects
//! the items' reference points.
//! - The LaTeX family (the [`latex`](crate::stdlib::backends::latex)
//! helpers and the `latex-recomposed` backend) owns the constructs
//! the recomposition rule stages; without them, that rule is set aside
//! (excluded from rule selection; see
//! [`PeerName`](crate::core::registry::PeerName)) and the registry still
//! builds.
//!
//! # Diagnostics
//!
//! Every condition is reported under `flm.lists.*` by the lowering rules;
//! each is an Error except the Note [`RefIgnored`], and each item's
//! documentation states the recovery: [`UnknownKey`], [`MissingValue`],
//! [`BadLabelForm`], [`BadLabel`], [`LabelNamesNumber`], [`RefIgnored`],
//! [`ContentBeforeItem`], [`MissingTag`], [`NoNumbering`],
//! [`ItemOutsideList`], [`NoEnumitemFormat`], [`NumberReadAsCharacters`].
//!
//! The mistakes in how a list is written (its optional arguments, the
//! content before its first item, an item missing its tag) and the problems
//! of the label beside its items (a template that cannot be used, a numbered
//! list that nothing numbers) are reported by whichever rule lowers the
//! list, so every backend reports them alike, the recomposed LaTeX included.
//! The recomposition rule alone reports [`NoEnumitemFormat`] and
//! [`NumberReadAsCharacters`], since only it writes a list's own templates as
//! LaTeX. A list's own template that does not compile is reported once: the
//! reference template of a numbered list in a registry with the numbering
//! feature by the numbering stage, which compiles it
//! (`flm.numbering.bad-number-format`), and every other template by the
//! list's rule ([`BadLabel`]).
//!
//! # Items of this module
//!
//! - The feature: [`Lists`], [`feature`], [`FEATURE`]; its configuration
//! [`ListsConfig`], [`ListKind`].
//! - Names: the elements [`LIST`] and [`ITEM`], the command [`ITEM_COMMAND`],
//! the scoped package [`PACKAGE`], the argument [`OPTIONS_ARG`] and its
//! keys [`LABEL_KEY`], [`REF_KEY`], [`TAG_KEY`], the reference kind
//! [`KIND`], the label types [`LABEL_TYPES`], the anchor prefix
//! [`ANCHOR_PREFIX`], the rules [`RULE`] and [`ITEM_RULE`].
//! - Element values: [`ListElement`], [`ItemElement`].
//! - Reading a list: [`list_items`], [`item_of`], [`is_item`],
//! [`enclosing_list`], [`nesting_chain`], [`ListBody`], [`ListItem`]; its
//! optional arguments: [`list_options`], [`item_options`], [`short_form`],
//! [`short_form_ref`], [`ListOptions`], [`OwnLabel`], [`ItemOptions`],
//! [`ItemTag`].
//! - Lowering: [`ListRule`], [`ItemRule`]; the recomposed LaTeX: [`latex`].
//! - Numbers: [`numbers`].
//! - Conditions: listed under [Diagnostics](#diagnostics).
use Arc;
use NodeRef;
use crateSettingsDecl;
use crate;
use crate;
use crate;
use crateon_worker_thread;
use crateFlm;
use crate;
use crate;
use crate;
use crate;
use cratepres;
use crate;
use craterefs;
pub use ;
pub use ;
pub use ;
use instance_chain;
pub use ;
pub use ;
pub use holds_placeholder;
use ;
/// The feature's registered name, `lists`.
pub const FEATURE: &str = "lists";
/// The declaration of the feature's settings: the fields of [`ListsConfig`]
/// are its keys. See [`crate::core::settings`].
/// The element type name shared by every list kind, `flm.lists.list`. Each
/// list kind is one element value of this type, carrying a
/// [`ListElement`].
pub const LIST: &str = "flm.lists.list";
/// The element of `\item`, `flm.lists.item`, carrying an [`ItemElement`].
pub const ITEM: &str = "flm.lists.item";
/// The name of the command that begins an item, `item`.
pub const ITEM_COMMAND: &str = "item";
/// The name of the scoped package ([`ScopedPackageDef`]) that holds
/// `\item`, `flm.lists.items`. The body of every list environment refers to
/// it, so `\item` can be written inside a list's body and nowhere else.
pub const PACKAGE: &str = "flm.lists.items";
/// The name of the optional key-value argument of a list environment and of
/// an `\item`, `options`.
pub const OPTIONS_ARG: &str = "options";
/// The key of a list environment's optional argument that gives the list's
/// own label template, `label`.
pub const LABEL_KEY: &str = "label";
/// The key of a list environment's optional argument that gives the list's
/// own reference template, `ref`: the name the LaTeX package `enumitem` gives
/// the same key.
pub const REF_KEY: &str = "ref";
/// The only key of an `\item`'s optional argument, `tag`: the item's tag.
pub const TAG_KEY: &str = "tag";
/// The reference kind of an item's reference point, `item`.
pub const KIND: &str = "item";
/// The label types an item accepts: `item` only. `\label{item:first}`
/// labels an item; a label of another type written after an `\item` defines
/// nothing and is reported by the label check as
/// `flm.refs.label-type-not-accepted`.
pub const LABEL_TYPES: = ;
/// The prefix of an item's anchor, `item`: an unlabeled item's anchor is
/// `item--<position><four letters>`, a labeled item's anchor is
/// `item-<label>` (see [`ANCHORS`](crate::stdlib::features::refs::ANCHORS)).
pub const ANCHOR_PREFIX: &str = LABEL_TYPES;
/// The name of the general lowering rule of the element [`LIST`],
/// `flm.lists.list.lower.default` ([`ListRule`]), the default on every
/// backend except `latex-recomposed`.
pub const RULE: &str = "flm.lists.list.lower.default";
/// The name of the lowering rule of the element [`ITEM`],
/// `flm.lists.item.lower.default` ([`ItemRule`]): the rule of an `\item`
/// that begins no item.
pub const ITEM_RULE: &str = "flm.lists.item.lower.default";
/// The data of one element value of [`LIST`]: the list kind it is.
/// The data of the [`ITEM`] element, and its [`Referenceable`] aspect, which
/// declares the reference point of the item an `\item` begins.
///
/// It holds the templates the feature compiled when the registry was built.
/// For an untagged item of an unnumbered list that writes no usable label of
/// its own, the reference point carries as its content the list kind's
/// fixed label template for the depth (the bullet), as the tree compiled
/// once for that template.
/// Declares one reference point per `\item` that begins an item of a list,
/// and none for any other `\item`. The point's labels are the `\label`
/// fields written after the `\item`, of the label type `item`; its anchor is
/// derived from its first label or, for an unlabeled item, from its
/// position.
///
/// An untagged item of a numbered list kind declares a number source
/// ([`NumberSource`]): the list kind's counter; the scoped instances under
/// which it is counted (below), outermost first; the counter style of its
/// list's depth, whose number format is the depth's reference template; the
/// advance of level 0 by one; and, as the number template, the list's own
/// reference template where the list writes one
/// ([`ListOptions::ref_template`]). The item's counter value is therefore
/// recorded in the form a reference to it shows, and the list's rule writes
/// the label beside the item from the same record.
///
/// # The content the reference point carries
///
/// A reference to an item shows what is shown beside the item, so the point
/// carries the item's label as its content wherever the label is not a
/// number:
///
/// - for a tagged item, its tag, however it is written (`\item[Custom]`,
/// `\item[tag=Custom]`, `\item[tag={Custom}]`); such an item declares no
/// number source, so it is counted in no counter;
/// - for an untagged item of an unnumbered list, the list's own label where
/// its bracket writes one that can be used (`[-]`, `[label=*]`,
/// `[label={--}]`), and otherwise the label template its list kind
/// declares for the depth, by default the bullet `•` of an `itemize`. A
/// list's own label that holds a placeholder (`label=#{arabic}`, `[1.]`)
/// is an error on an unnumbered list ([`LabelNamesNumber`]); the item
/// shows the depth's label instead, and a reference to the item shows the
/// same;
/// - for any other item, nothing: its number is what a reference shows.
///
/// This content is not a node of the document that the point could refer to
/// (a bullet comes from the configuration, and `Custom` in `tag=Custom`
/// shares a run of characters with its key), so the point carries it as a
/// small tree of its own ([`ContentRef::Synthesized`]). The bullet's tree is
/// built once per configured template, when the registry is built, and
/// shared by every item that shows it. A tag or a list's own label is copied
/// into a new tree each time the points are computed, which the
/// [`refpoints`](crate::stdlib::features::refpoints) feature does once per
/// run.
///
/// # The scoped instances under which an item is counted
///
/// Each list is a scoped instance of its list kind's counter (see
/// [scoped instances](crate::model::aspects::NumberSource#scoped-instances)),
/// and a nested list's instance is numbered within the number of the item
/// that holds it. A tagged item has no number, so no list can be numbered
/// within it. An item is therefore counted under its own list and, among the
/// enclosing lists of the same list kind, under each one whose item holding
/// the nested list is untagged. A list held by a tagged item, or written
/// before the first `\item` of the enclosing list, is numbered within the
/// nearest untagged item of its list kind further out; where there is none,
/// it is an outermost instance. The nesting depth, which selects the counter
/// style, still counts every enclosing list of the list kind. In an
/// `enumerate`, `\item[T] \begin{enumerate}\item x\end{enumerate}` therefore
/// numbers `x` as `(i)` regardless of the items before `T`, and no nesting
/// joiner writes a number of the enclosing list.
/// The element value of the list kind `name`: a block element carrying the
/// list kind.
/// The element value of `\item`: a block element, so that it remains a
/// direct child of a list's body, between the blocks of the items; its
/// reference point reads the list kinds' compiled label templates `labels`.
/// The scoped package [`PACKAGE`], declared by `owner`, holding `\item` with
/// its optional argument and its `\label` fields; `labels` are the list
/// kinds' compiled label templates, which an item's reference point reads.
/// The `lists` feature ([`FlmFeature`]). Under a [`ListsConfig`], it
/// registers one `flm.lists.list` element value per list kind, written as
/// the environment of the list kind's name; the scoped package holding
/// `\item`; the counters and counter styles of the numbered list kinds, as
/// peer contributions to the numbering feature; the build hook
/// ([`LateInit`](crate::core::registry::LateInit)) that compiles every list
/// kind's label templates and a numbered list kind's reference templates;
/// and the lowering rules [`RULE`], [`ITEM_RULE`] and
/// [`latex::LATEX_RULE`]. See the
/// [module documentation](self#what-the-feature-registers).
/// The [`Lists`] feature under the default configuration (the list kinds
/// `itemize`, `enumerate` and `description`), ready to be listed in a
/// package entry.
///
/// Use `Arc::new(Lists::new(config))` to list the feature under a
/// [`ListsConfig`] of your own.