@@ -20,6 +20,7 @@ pub(crate) struct Id<'a> {
20
20
/// An [`Element`] container
21
21
#[ derive( Clone , Debug ) ]
22
22
pub struct Group < ' a > {
23
+ pub ( crate ) primary_level : Option < Level < ' a > > ,
23
24
pub ( crate ) elements : Vec < Element < ' a > > ,
24
25
}
25
26
@@ -31,7 +32,10 @@ impl Default for Group<'_> {
31
32
32
33
impl < ' a > Group < ' a > {
33
34
pub fn new ( ) -> Self {
34
- Self { elements : vec ! [ ] }
35
+ Self {
36
+ primary_level : None ,
37
+ elements : vec ! [ ] ,
38
+ }
35
39
}
36
40
37
41
pub fn element ( mut self , section : impl Into < Element < ' a > > ) -> Self {
@@ -44,6 +48,16 @@ impl<'a> Group<'a> {
44
48
self
45
49
}
46
50
51
+ /// Set the primary [`Level`] for this [`Group`].
52
+ ///
53
+ /// If not specified, if the first element in a [`Group`] is a [`Title`]
54
+ /// then its [`Level`] will be used, if no it will default to
55
+ /// [`Level::ERROR`].
56
+ pub fn primary_level ( mut self , level : Level < ' a > ) -> Self {
57
+ self . primary_level = Some ( level) ;
58
+ self
59
+ }
60
+
47
61
pub fn is_empty ( & self ) -> bool {
48
62
self . elements . is_empty ( )
49
63
}
@@ -264,7 +278,8 @@ impl<'a> Annotation<'a> {
264
278
pub enum AnnotationKind {
265
279
/// An [`Annotation`] which will use the "primary" underline character ('^'
266
280
/// for [`OutputTheme::Ascii`], and '━' for [`OutputTheme::Unicode`]) and
267
- /// be colored according to the primary [`Level`] of the [`Group`].
281
+ /// be colored according to the primary [`Level`] of the [`Group`], see
282
+ /// [`Group::primary_level`] for details about how this is set.
268
283
Primary ,
269
284
/// An [`Annotation`] which will use the "secondary" underline character (
270
285
/// '-' for [`OutputTheme::Ascii`], and '─' for [`OutputTheme::Unicode`])
0 commit comments