WebBits-0.15: JavaScript analysis tools




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


HTML Data Structures

data Attribute a s Source


Typeable2 Attribute 
Functor (Attribute a) 
Foldable (Attribute a) 
Traversable (Attribute a) 
(Eq a, Eq s) => Eq (Attribute a s) 
(Data a, Data s) => Data (Attribute a s) 
(Show a, Show s) => Show (Attribute a s) 

data Html a sc Source


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 


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) 

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.