@@ -20,6 +20,7 @@ pub(crate) struct Id<'a> {
2020/// An [`Element`] container
2121#[ derive( Clone , Debug ) ]
2222pub struct Group < ' a > {
23+ pub ( crate ) primary_level : Option < Level < ' a > > ,
2324 pub ( crate ) elements : Vec < Element < ' a > > ,
2425}
2526
@@ -31,7 +32,10 @@ impl Default for Group<'_> {
3132
3233impl < ' a > Group < ' a > {
3334 pub fn new ( ) -> Self {
34- Self { elements : vec ! [ ] }
35+ Self {
36+ primary_level : None ,
37+ elements : vec ! [ ] ,
38+ }
3539 }
3640
3741 pub fn element ( mut self , section : impl Into < Element < ' a > > ) -> Self {
@@ -44,6 +48,16 @@ impl<'a> Group<'a> {
4448 self
4549 }
4650
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+
4761 pub fn is_empty ( & self ) -> bool {
4862 self . elements . is_empty ( )
4963 }
@@ -264,7 +278,8 @@ impl<'a> Annotation<'a> {
264278pub enum AnnotationKind {
265279 /// An [`Annotation`] which will use the "primary" underline character ('^'
266280 /// 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.
268283 ///
269284 /// [`OutputTheme::Ascii`]: crate::renderer::OutputTheme
270285 /// [`OutputTheme::Unicode`]: crate::renderer::OutputTheme
0 commit comments