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
//! The configuration of the [`defterm`](super) feature, [`DeftermConfig`]:
//! the lead-in template that opens every term definition.
use ;
/// The lead-in template of every term definition by default, `#{term}: `:
/// the term, a colon and a space, run into the first paragraph of the term
/// definition, as in `Entropy: A measure of disorder.`
pub const DEFAULT_LEAD_IN: &str = "#{term}: ";
/// The configuration of the [`Defterm`](super::Defterm) feature: the
/// **lead-in**, the text that a term definition (a `defterm` environment)
/// shows before the words of its first paragraph, usually the term being
/// defined.
///
/// The lead-in is a template in the [template
/// language](crate::guide::concepts_overview#the-template-language-shared-by-features)
/// (described for authors under [the template
/// language](crate::guide::language_syntax#the-template-language)), with one
/// placeholder: `#{term}` is the term as the term definition writes it,
/// markup included. The rest of the template is ordinary FLM markup, and
/// markup may enclose the placeholder. `#{term}: ` is the default, and
/// `\textbf{Definition} (\emph{#{term}}): ` a richer lead-in. A template
/// without `#{term}` is allowed: every term definition then opens with the
/// same words. A template may use `#{term}` once at most, because the term is
/// shown only once, where the term definition is written.
///
/// `None` sets no lead-in: a term definition is then its body alone. A blank
/// template is not a way to say so: it fails the registry build.
///
/// The value is what [`Defterm::new`](super::Defterm::new) takes, and a host
/// passes it through
/// [`StdlibConfig::defterm`](crate::stdlib::StdlibConfig::defterm). It is
/// the feature's configuration, fixed when the registry is built (see
/// [settings, options and
/// configuration](crate::guide::concepts_overview#settings-options-and-configuration)):
/// the template is compiled once then, and a template that does not compile
/// fails the registry build with a message that quotes it. It enters the
/// registry digest ([`digest_bytes`](DeftermConfig::digest_bytes)).
///
/// # Examples
///
/// ```
/// use flm_core::stdlib::features::defterm::{DeftermConfig, DEFAULT_LEAD_IN};
///
/// assert_eq!(DeftermConfig::new().lead_in.as_deref(), Some(DEFAULT_LEAD_IN));
///
/// let richer = DeftermConfig::new()
/// .lead_in(Some(r"\textbf{Definition} (\emph{#{term}}): ".to_string()));
/// assert!(richer.lead_in.is_some());
///
/// // No lead-in: a definition is its body alone.
/// assert!(DeftermConfig::new().lead_in(None).lead_in.is_none());
/// ```