willow-0.1.0.0: An implementation of the web Document Object Model, and its rendering.
Copyright(c) 2020-2021 Sam May
LicenseMPL-2.0
Maintainerag.eitilt@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell98

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

Structure

data Tree Source #

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 

Fields

  • node :: Node

    The atomic portion of the tree at the current location.

  • children :: [Tree]

    All parts of the tree nested below the current location.

Instances

Instances details
Eq Tree Source # 
Instance details

Defined in Web.Willow.DOM

Methods

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

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

Read Tree Source # 
Instance details

Defined in Web.Willow.DOM

Show Tree Source # 
Instance details

Defined in Web.Willow.DOM

Methods

showsPrec :: Int -> Tree -> ShowS #

show :: Tree -> String #

showList :: [Tree] -> ShowS #

emptyTree :: Tree Source #

A sane default collection for easy record initialization; namely, a Document without any children.

data Node Source #

DOM: node

The sum type of all different classes of behaviour a particular point of data may fill.

Constructors

Text Text

DOM: Text

A simple character string to be rendered to the output or to be processed further, according to which Elements enclose it.

Comment Text

DOM: Comment

An author's aside, not intended to be shown to the end user.

DocumentType DocumentTypeParams

DOM: DocumentType

Largely vestigial in HTML5, but used in previous versions and related languages to specify the semantics of Elements used in the document.

Element ElementParams

DOM: Element

Markup instructions directing the behaviour or classifying a portion of the document's content.

Attribute AttributeParams

DOM: Attr

Metadata allowing finer customization and description of the heavier Elements.

DocumentFragment

DOM: DocumentType

As like Document, but requiring less precise structure in its children and generally only containing a small slice of a larger document.

Document QuirksMode

DOM: Document

The root of a Tree, typically imposing a principled structure.

Instances

Instances details
Eq Node Source # 
Instance details

Defined in Web.Willow.DOM

Methods

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

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

Read Node Source # 
Instance details

Defined in Web.Willow.DOM

Show Node Source # 
Instance details

Defined in Web.Willow.DOM

Methods

showsPrec :: Int -> Node -> ShowS #

show :: Node -> String #

showList :: [Node] -> ShowS #

data NodeType Source #

A simplified view of the Node constructors, for use in testing via nodeType.

nodeType :: Node -> Maybe NodeType Source #

DOM: nodeType

Simplify the algebraic data type to a one-dimensional Enum to allow equality testing rather than requiring pattern matching.

Data

Document

data QuirksMode Source #

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: no-quirks mode

Fully compliant with the modern standard.

LimitedQuirks

DOM: limited-quirks mode

Largely compliant with the standard, except for a couple height calculations.

FullQuirks

DOM: quirks mode

Backwards compatibility with 1990's-era technology.

Instances

Instances details
Bounded QuirksMode Source # 
Instance details

Defined in Web.Willow.DOM

Enum QuirksMode Source # 
Instance details

Defined in Web.Willow.DOM

Eq QuirksMode Source # 
Instance details

Defined in Web.Willow.DOM

Ord QuirksMode Source # 
Instance details

Defined in Web.Willow.DOM

Read QuirksMode Source # 
Instance details

Defined in Web.Willow.DOM

Show QuirksMode Source # 
Instance details

Defined in Web.Willow.DOM

Elements

data ElementParams Source #

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

emptyElementParams :: ElementParams Source #

A sane default collection for easy record initialization.

type ElementName = Text Source #

Type-level clarification for the name of a markup tag.

type ElementPrefix = Text Source #

Type-level clarification for the short namespace reference classifying a markup tag.

Attribute list

type AttributeMap = HashMap (Maybe Namespace, AttributeName) (Maybe AttributePrefix, AttributeValue) Source #

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 Source #

Pack a list of key-value metadata pairs into a form better optimized for random lookup.

toAttrList :: AttributeMap -> [AttributeParams] Source #

Extract the key-value metadata pairs from a indexed collection into an iterable form. The order of elements is unspecified.

insertAttribute :: AttributeParams -> AttributeMap -> AttributeMap Source #

As insert, performing the required data reordering for the less-comfortable internal type representation.

Attributes

type BasicAttribute = (AttributeName, AttributeValue) Source #

A simple key-value representation of an attribute on an HTML tag, before any namespace processing.

data AttributeParams Source #

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

emptyAttributeParams :: AttributeParams Source #

A sane default collection for easy record initialization; namely, Nothings and emptys.

type AttributeName = Text Source #

Type-level clarification for the key of a supplemental point of metadata.

type AttributeValue = Text Source #

Type-level clarification for the value of a supplemental point of metadata.

type AttributePrefix = Text Source #

Type-level clarification for the short namespace reference classifying a supplemental point of metadata.

Document type declarations

data DocumentTypeParams Source #

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

emptyDocumentTypeParams :: DocumentTypeParams Source #

A sane default collection for easy record initialization; namely, emptys.

type DoctypeName = Text Source #

Type-level clarification for the language used in the document or, equivalently, the name of the root node.

type DoctypePublicId = Text Source #

Type-level clarification for a registered or otherwise globally-unique reference to a description of the language used in the document.

type DoctypeSystemId = Text Source #

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

type Namespace = Text Source #

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.

htmlNamespace :: Namespace Source #

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 Source #

Infra: MathML namespace

The canonical scope value for elements and attributes defined by the MathML standard.

svgNamespace :: Namespace Source #

Infra: SVG namespace

The canonical scope value for elements and attributes defined by the SVG standard.

xlinkNamespace :: Namespace Source #

Infra: XLink namespace

The canonical scope value for elements and attributes defined by the XLink standard.

xmlNamespace :: Namespace Source #

Infra: XML namespace

The canonical scope value for elements and attributes defined by the XML standard.

xmlnsNamespace :: Namespace Source #

Infra: XMLNS namespace

The canonical scope value for elements and attributes defined by the XMLNS standard.