html_outliner/
sectioning_type.rs1#[derive(Debug, Copy, Clone, Eq, PartialEq)]
3pub enum SectioningType {
4 Article,
7 Aside,
9 Nav,
11 Section,
13
14 Root,
17 Body,
19 Heading,
21}
22
23impl SectioningType {
24 #[inline]
25 pub(crate) fn is_sectioning_content_type(&self) -> bool {
26 matches!(
27 self,
28 SectioningType::Article
29 | SectioningType::Aside
30 | SectioningType::Nav
31 | SectioningType::Section
32 )
33 }
34
35 #[inline]
36 pub(crate) fn is_heading(&self) -> bool {
37 matches!(self, SectioningType::Heading)
38 }
39
40 #[inline]
42 pub fn from_sectioning_content_tag<S: AsRef<str>>(s: S) -> Option<SectioningType> {
43 let s = s.as_ref();
44
45 match s {
46 "article" => Some(SectioningType::Article),
47 "aside" => Some(SectioningType::Aside),
48 "nav" => Some(SectioningType::Nav),
49 "section" => Some(SectioningType::Section),
50 _ => None,
51 }
52 }
53
54 #[inline]
56 pub fn as_str(&self) -> &'static str {
57 match self {
58 SectioningType::Article => "article",
59 SectioningType::Aside => "aside",
60 SectioningType::Nav => "nav",
61 SectioningType::Section => "section",
62 SectioningType::Root => "root",
63 SectioningType::Body => "body",
64 SectioningType::Heading => "heading",
65 }
66 }
67}