Copyright | (c) 2020-2021 Sam May |
---|---|
License | MPL-2.0 |
Maintainer | ag.eitilt@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell98 |
Web.Willow.DOM
Description
In lieu of a fully-featured DOM implementation ---and even, for that matter, a styled tree--- this module provides bare-bones data structures to temporarily contain the minimal data currently returned by tree parsing. Eventually this will be padded out into a fully-featured DOM implementation, but doing so now would be creating much more work than necessary.
Synopsis
- data Tree = Tree {}
- emptyTree :: Tree
- data Node
- data NodeType
- nodeType :: Node -> Maybe NodeType
- data QuirksMode
- data ElementParams = ElementParams {}
- emptyElementParams :: ElementParams
- type ElementName = Text
- type ElementPrefix = Text
- type AttributeMap = HashMap (Maybe Namespace, AttributeName) (Maybe AttributePrefix, AttributeValue)
- fromAttrList :: [AttributeParams] -> AttributeMap
- toAttrList :: AttributeMap -> [AttributeParams]
- insertAttribute :: AttributeParams -> AttributeMap -> AttributeMap
- type BasicAttribute = (AttributeName, AttributeValue)
- data AttributeParams = AttributeParams {}
- emptyAttributeParams :: AttributeParams
- type AttributeName = Text
- type AttributeValue = Text
- type AttributePrefix = Text
- data DocumentTypeParams = DocumentTypeParams {}
- emptyDocumentTypeParams :: DocumentTypeParams
- type DoctypeName = Text
- type DoctypePublicId = Text
- type DoctypeSystemId = Text
- type Namespace = Text
- htmlNamespace :: Namespace
- mathMLNamespace :: Namespace
- svgNamespace :: Namespace
- xlinkNamespace :: Namespace
- xmlNamespace :: Namespace
- xmlnsNamespace :: Namespace
Structure
DOM:
tree
The core concept underlying HTML and related languages: a nested collection
of data and metadata marked up according to several broad categories.
Values may be easily instantiated as updates to emptyTree
.
Constructors
Tree | |
DOM:
node
The sum type of all different classes of behaviour a particular point of data may fill.
Constructors
Text Text | DOM:
A simple character string to be rendered to the output or to be
processed further, according to which |
Comment Text | DOM:
An author's aside, not intended to be shown to the end user. |
DocumentType DocumentTypeParams | DOM:
Largely vestigial in HTML5, but used in previous versions and
related languages to specify the semantics of |
Element ElementParams | DOM:
Markup instructions directing the behaviour or classifying a portion of the document's content. |
Attribute AttributeParams | DOM:
Metadata allowing finer customization and description of the heavier
|
DocumentFragment | DOM:
As like |
Document QuirksMode | DOM:
The root of a |
Constructors
ElementNode | DOM:
|
AttributeNode | DOM:
|
TextNode | DOM:
|
CDataSectionNode | DOM:
|
EntityReferenceNode | Deprecated: historical |
EntityNode | Deprecated: historical DOM:
|
ProcessingInstructionNode | |
CommentNode | DOM:
|
DocumentNode | DOM:
|
DocumentTypeNode | DOM:
|
DocumentFragmentNode | |
NotationNode | Deprecated: historical DOM:
|
Instances
Bounded NodeType # | |
Enum NodeType # | |
Eq NodeType # | |
Ord NodeType # | |
Defined in Web.Willow.DOM | |
Read NodeType # | |
Show NodeType # | |
Data
Document
data QuirksMode #
Through the long history of HTML browsers, many unique and/or buggy behaviours have become enshrined due to the simple fact that website authors used them. As the standards and the parse engines have continued to develop, three separated degrees of emulation have emerged for that backwards compatibility.
Constructors
NoQuirks | DOM:
Fully compliant with the modern standard. |
LimitedQuirks | DOM:
Largely compliant with the standard, except for a couple height calculations. |
FullQuirks | DOM:
Backwards compatibility with 1990's-era technology. |
Instances
Elements
data ElementParams #
DOM:
Element
The collection of metadata identifying and describing a markup tag used to
associate text or other data with its broader role in the document, or to
indicate a preferred rendering. Values may be easily instantiated as
updates to emptyElementParams
.
Constructors
ElementParams | |
Fields
|
Instances
Eq ElementParams # | |
Defined in Web.Willow.DOM Methods (==) :: ElementParams -> ElementParams -> Bool # (/=) :: ElementParams -> ElementParams -> Bool # | |
Read ElementParams # | |
Defined in Web.Willow.DOM Methods readsPrec :: Int -> ReadS ElementParams # readList :: ReadS [ElementParams] # | |
Show ElementParams # | |
Defined in Web.Willow.DOM Methods showsPrec :: Int -> ElementParams -> ShowS # show :: ElementParams -> String # showList :: [ElementParams] -> ShowS # |
emptyElementParams :: ElementParams #
A sane default collection for easy record initialization.
type ElementName = Text #
Type-level clarification for the name of a markup tag.
type ElementPrefix = Text #
Type-level clarification for the short namespace reference classifying a markup tag.
Attribute list
type AttributeMap = HashMap (Maybe Namespace, AttributeName) (Maybe AttributePrefix, AttributeValue) #
DOM:
NamedNodeMap
Type-level clarification for the collection of key-value points of
supplemental metadata attached to an Element
. Note that, while an
Attribute
's prefix is used to determine the associated namespace (and
needs to be tracked for round-trip serialization), it doesn't factor into
testing equality or in lookups.
fromAttrList :: [AttributeParams] -> AttributeMap #
Pack a list of key-value metadata pairs into a form better optimized for random lookup.
toAttrList :: AttributeMap -> [AttributeParams] #
Extract the key-value metadata pairs from a indexed collection into an iterable form. The order of elements is unspecified.
insertAttribute :: AttributeParams -> AttributeMap -> AttributeMap #
As insert
, performing the required data reordering for the
less-comfortable internal type representation.
Attributes
type BasicAttribute = (AttributeName, AttributeValue) #
A simple key-value representation of an attribute on an HTML tag, before any namespace processing.
data AttributeParams #
DOM:
Attr
A more complete representation of an attribute, including extensions beyond
the BasicAttribute
to support more structured (XML-like) markup languages.
Values may be easily instantiated as updates to emptyAttributeParams
.
Constructors
AttributeParams | |
Fields
|
Instances
Eq AttributeParams # | |
Defined in Web.Willow.DOM Methods (==) :: AttributeParams -> AttributeParams -> Bool # (/=) :: AttributeParams -> AttributeParams -> Bool # | |
Read AttributeParams # | |
Defined in Web.Willow.DOM Methods readsPrec :: Int -> ReadS AttributeParams # readList :: ReadS [AttributeParams] # | |
Show AttributeParams # | |
Defined in Web.Willow.DOM Methods showsPrec :: Int -> AttributeParams -> ShowS # show :: AttributeParams -> String # showList :: [AttributeParams] -> ShowS # |
type AttributeName = Text #
Type-level clarification for the key of a supplemental point of metadata.
type AttributeValue = Text #
Type-level clarification for the value of a supplemental point of metadata.
type AttributePrefix = Text #
Type-level clarification for the short namespace reference classifying a supplemental point of metadata.
Document type declarations
data DocumentTypeParams #
DOM:
DocumentType
The collection of metadata representing a document type declaration
describing the markup language used in a document; of vestigal use in HTML,
but important for related languages. Values may be easily instantiated as
updates to emptyDocumentTypeParams
.
Constructors
DocumentTypeParams | |
Fields
|
Instances
Eq DocumentTypeParams # | |
Defined in Web.Willow.DOM Methods (==) :: DocumentTypeParams -> DocumentTypeParams -> Bool # (/=) :: DocumentTypeParams -> DocumentTypeParams -> Bool # | |
Read DocumentTypeParams # | |
Defined in Web.Willow.DOM Methods readsPrec :: Int -> ReadS DocumentTypeParams # readList :: ReadS [DocumentTypeParams] # | |
Show DocumentTypeParams # | |
Defined in Web.Willow.DOM Methods showsPrec :: Int -> DocumentTypeParams -> ShowS # show :: DocumentTypeParams -> String # showList :: [DocumentTypeParams] -> ShowS # |
emptyDocumentTypeParams :: DocumentTypeParams #
A sane default collection for easy record initialization; namely,
empty
s.
type DoctypeName = Text #
Type-level clarification for the language used in the document or, equivalently, the name of the root node.
type DoctypePublicId = Text #
Type-level clarification for a registered or otherwise globally-unique reference to a description of the language used in the document.
type DoctypeSystemId = Text #
Type-level clarification for a reference to the description of the language used in the document, dependant on the state of the system (and/or the internet).
Namespaces
XML-NAMES:
XML namespace
An identifier (theoretically) pointing to a reference defining a particular element or attribute ---though not necessarily in machine-readable form--- and so providing a scope for differentiating multiple elements with the same local name but different semantics.
Infra:
HTML namespace
The canonical scope value for elements and attributes defined by the HTML standard when used in XML or XML-compatible documents.
mathMLNamespace :: Namespace #
Infra:
MathML namespace
The canonical scope value for elements and attributes defined by the MathML standard.
Infra:
SVG namespace
The canonical scope value for elements and attributes defined by the SVG standard.
Infra:
XLink namespace
The canonical scope value for elements and attributes defined by the XLink standard.
Infra:
XML namespace
The canonical scope value for elements and attributes defined by the XML standard.
Infra:
XMLNS namespace
The canonical scope value for elements and attributes defined by the XMLNS standard.