Safe Haskell | None |
---|
This module exports various useful utility functions for working with XmlHtml Nodes. For example, the equality operator on Node does a structural comparison of the nodes. However, this is not entirely useful, since transformed nodes may be equal but e.g. have their attributes in a different order in the list. Among other things, this module defines an EqNode type which has an Eq instance that does semantic equality instead of structural equality.
Types
Functions
Equality
attrsEq :: [(Text, Text)] -> [(Text, Text)] -> BoolSource
Test a list of attributes for equality. This has special handling for the class attribute, so that the order in which the classes are applied to the node doesn't matter. Additionally, the oder of the attributes in either list is also ignored.
Utility
stripWhitespaceNodes :: Node -> Maybe NodeSource
Strip nodes that contain only whitespace. This can be useful when doing equality comparisons of trees (e.g. in testing). XmlHtml keeps all whitespace, which can cause structural equality differences in trees which were produced programattically vs. hand written and nicely formatted trees.