ahtml_html/
types.rs

1//! These are parts from the html / html-sys crates, <https://github.com/yoshuawuyts/html>
2
3//! Copyright 2020 Yoshua Wuyts, license MIT or Apache as per the project above.
4
5use kstring::KString;
6use serde::{Deserialize, Serialize};
7
8/// An attribute
9#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10pub struct Attribute {
11    pub name: KString,
12    pub description: KString,
13    pub field_name: KString,
14    pub ty: AttributeType,
15}
16
17#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
18pub enum AttributeType {
19    Bool,
20    KString,
21    Integer,
22    Float,
23    Identifier(KString),
24    Enumerable(Vec<KString>),
25}
26
27/// The final source of truth we used to generate code from.
28///
29/// Created by combining all of the previously parsed data.
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct MergedElement {
32    pub tag_name: KString,
33    pub struct_name: KString,
34    pub submodule_name: KString,
35    pub mdn_link: KString,
36    pub has_global_attributes: bool,
37    pub has_closing_tag: bool,
38    pub attributes: Vec<Attribute>,
39    pub dom_interface: KString,
40    pub content_categories: Vec<MergedCategory>,
41    pub permitted_child_elements: Vec<KString>,
42}
43
44/// Each element in HTML falls into zero or more categories that group elements
45/// with similar characteristics together.
46///
47/// Unlike `ParsedCategory`, this can no longer hold any child elements.
48#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
49pub enum MergedCategory {
50    Metadata,
51    Flow,
52    Sectioning,
53    Heading,
54    Phrasing,
55    Embedded,
56    Interactive,
57    Palpable,
58    ScriptSupporting,
59    Transparent,
60}