html_parser
Types
Attribute is an HTML attribute key-value pair
pub type Attribute {
Attribute(key: String, value: String)
}
Constructors
-
Attribute(key: String, value: String)
Element is a part of an HTML document
pub type Element {
EmptyElement
StartElement(
name: String,
attributes: List(Attribute),
children: List(Element),
)
EndElement(name: String)
Content(String)
}
Constructors
-
EmptyElement
-
StartElement( name: String, attributes: List(Attribute), children: List(Element), )
StartElement is an opening tag like
and can have Attributes and child ElementsEndElement(name: String)
EndElement just has a name and signals the end of a block
Content(String)
Content is non-HTML parts of the document in-between StartElement and EndElement (the “hello” in
<div>hello</div>
)
Functions
pub fn get_attrs(in: String) -> #(List(Attribute), String)
get the attributes for a StartElement and remaining String
pub fn get_first_element(in: String) -> #(Element, String)
get the first Element and remaining String