html-parse-0.2.1.0: A high-performance HTML tokenizer
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.HTML.Tree

Synopsis

Constructing forests

tokensToForest :: [Token] -> Either ParseTokenForestError (Forest Token) Source #

construct a Forest from a Token list.

This code correctly handles void elements. Void elements are required to have a start tag and must not have an end tag. See nonClosing.

This code does not correctly handle optional tags. It assumes all optional start and end tags are present.

https://www.w3.org/TR/html52/syntax.html#optional-tags

data PStack Source #

Instances

Instances details
Show PStack Source # 
Instance details

Defined in Text.HTML.Tree

Eq PStack Source # 
Instance details

Defined in Text.HTML.Tree

Methods

(==) :: PStack -> PStack -> Bool #

(/=) :: PStack -> PStack -> Bool #

nonClosing :: [Text] Source #

void elements which must not have an end tag

This list does not include the obsolete <command> and <keygen> elements.

 nonClosing = ["br", "hr", "img", "meta", "area", "base", "col", "embed", "input", "link", "param", "source", "track", "wbr"]

https://www.w3.org/TR/html52/syntax.html#void-elements

Deconstructing forests

tokensFromForest :: Forest Token -> [Token] Source #

convert a Forest of Token into a list of Token.

This code correctly handles void elements. Void elements are required to have a start tag and must not have an end tag. See nonClosing.

tokensFromTree :: Tree Token -> [Token] Source #

convert a Tree of Token into a list of Token.

This code correctly handles void elements. Void elements are required to have a start tag and must not have an end tag. See nonClosing.