WebBits-0.9.3: JavaScript analysis tools

WebBits.Html.Syntax

Contents

Description

Datatypes for HTML parameterized over an annotation type and a script type.

Synopsis

HTML Data Structures

data Html a sc Source

Constructors

Element HtmlId [Attribute a sc] [Html a sc] a 
Text String a 
Comment String a 
HtmlSeq [Html a sc]

must be a non-empty list

ProcessingInstruction String a 
InlineScript sc a String 
Script sc a 

Instances

Typeable2 Html 
Functor (Html a) 
Foldable (Html a) 
Traversable (Html a) 
(Eq a, Eq sc) => Eq (Html a sc) 
(Data a, Data sc) => Data (Html a sc) 
(Show a, Show sc) => Show (Html a sc) 
PrettyPrintable s => PrettyPrintable (Html a s) 

The Script class

class Script t whereSource

A type t of the Script class can be parsed using Parsec. t is of kind '* -> *', as the parsed AST should be annotated with souce locations (see SourcePos).

The big deal here is that we can embed a parser for some scripting language, (e.g. Javascript) into this HTML parser with ease, while preserving source locations. The Html datatype is parameterized over a script parser (an instance of Script).

Miscellaneous Functions

attributeValue :: HtmlId -> [Attribute a s] -> Maybe StringSource

Returns the value of the attribute in the list, or Nothing if it doesn't exist of the value is an inline-expression.