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
/// The HTML source position /// /// # Examples /// ``` /// # use self::htmlstream::*; /// let pos = Position { /// start: 0, /// end: 10, /// }; /// ``` #[derive(Debug, PartialEq)] pub struct Position { pub start: usize, pub end: usize, } /// The tag state /// /// + `Text`: not a HTML tag, e.g. hello /// + `Opening`: an opening tag, e.g. <a href="#"> /// + `Closing`: a closing tag, e.g. </a> /// + `SelfClosing`: a selfclosing tag,e.g. <br /> #[derive(Debug, PartialEq)] pub enum HTMLTagState { Text, Opening, Closing, SelfClosing } /// The HTML tag /// /// # Examples /// /// ``` /// # use self::htmlstream::*; /// let tag = HTMLTag { /// name: "a".to_string(), /// html: "<a href=\"#\">link</a>".to_string(), /// attributes: "href=\"#\"".to_string(), /// state: HTMLTagState::Opening, /// }; /// ``` #[derive(Debug, PartialEq)] pub struct HTMLTag { pub name: String, pub html: String, pub attributes: String, pub state: HTMLTagState } /// The tag attribute /// /// # Examples /// /// ``` /// # use self::htmlstream::*; /// let attr = HTMLTagAttribute { /// name: "href".to_string(), /// value: "#".to_string(), /// }; /// ``` #[derive(Debug, PartialEq)] pub struct HTMLTagAttribute { pub name: String, pub value: String, }