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
//! The functions that build the element of a field declared in a scoped
//! package and that read a field node.
//!
//! A [field](crate::guide::concepts_overview#fields-data-a-construct-reads) is a
//! macro that a construct absorbs as data rather than as content: the
//! `\label{sec:intro}` written after `\section{Introduction}`, and the `\label`,
//! `\tag`, `\nonumber` and `\\` written inside the body of a display-math
//! environment. A field says something about the construct that reads it (this
//! heading carries this label, this equation line is not numbered) and is not
//! content at the place where it is written.
//!
//! Every field node is a macro node that carries an element named
//! [`FIELD`] (`flm.field`), and the node's macro name is the field's name as
//! written. Nothing in the library interprets a field by its name across the
//! whole document: the construct that declared the field is the only reader
//! of it, and it reads it by the name it declared ([`field_name`],
//! [`is_field_named`]).
//!
//! A field node that reaches a backend's lowering means that a construct did not
//! read its data, which is a fault of that construct. The only lowering rule of
//! the field element therefore reports an error on every backend
//! ([`FieldRule`](crate::stdlib::backends::lowering::FieldRule)).
//!
//! Fields are declared in two ways:
//!
//! - as [tack-on fields](super::TackOnField) of a tack-on argument
//! ([`ArgStdKind::TackOn`](super::ArgStdKind::TackOn)), the argument that
//! absorbs the field macros written at its position in a call, after the
//! arguments declared before it; this is how `\label` is written after a
//! heading. A tack-on field is data only: its node carries the language's
//! own field element, the [structural element](crate::lang::structural)
//! [`FIELD`];
//! - as ordinary macro declarations of a [scoped
//! package](super::ScopedPackageDef) whose element is built with
//! [`field_element`]; this is how the `math` feature declares the four
//! commands of an equation line inside a display-math environment's body.
// One element serves every field, rather than one per field name chosen by the
// declarer: an element is what a node means to the whole library, and a field means
// something only to its construct, so a definition's own `\label` field is never taken
// for the label of the references feature.
use Arc;
use NodeRef;
use crate;
use crate;
use crateFlm;
use crateFIELD;
/// Creates the element of a field that a scoped package declares as one of its
/// macros: an element named [`FIELD`], documented with `docs`.
///
/// `docs` is the element's documentation; pass what the field is for. The
/// element's block role is the default one
/// ([`BlockRole::DEFAULT`](crate::model::aspects::BlockRole::DEFAULT)), as
/// for the language's own field element. A [tack-on
/// field](super::TackOnField) needs no element: its node carries the
/// language's own.
/// Returns the field name of `node`, the name its macro is written with
/// (`label` for a `\label` field node), or `None` when `node` is not a field
/// node.
///
/// A construct uses it to pick its own fields out of the nodes it absorbed, by
/// comparing the name with the names it declared. [`is_field_named`] makes the
/// comparison for one name.
/// Returns whether `node` is a field node written `\name`.
///
/// A construct that reads one field, such as a heading reading its `\label`
/// fields, tests every node it absorbed with this function.