haquery-0.1.1.3: jQuery for Haskell.

Safe HaskellNone
LanguageHaskell98

Haquery

Contents

Description

Haquery is jQuery for Haskell.

Known problems:

Some selectors need explicit * to work: ":eq(0)" does not work but "*:eq(0)" does, same with "> b": "* > b", etc.

Synopsis

Types

data Attrs Source #

Instances

Eq Attrs Source # 

Methods

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

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

Show Attrs Source # 

Methods

showsPrec :: Int -> Attrs -> ShowS #

show :: Attrs -> String #

showList :: [Attrs] -> ShowS #

data Tag Source #

Constructors

Doctype [Int] Text 
Text [Int] Text 
Tag [Int] Text Attrs [Child] 

Instances

Eq Tag Source # 

Methods

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

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

Show Tag Source #

Show is used for pretty printing, for actual rendering/serialization use render.

Methods

showsPrec :: Int -> Tag -> ShowS #

show :: Tag -> String #

showList :: [Tag] -> ShowS #

type Child = Tag Source #

Rendering

render :: Tag -> Text Source #

Render tag to text.

Tag creation

tag :: Text -> [(Text, Text)] -> [Tag] -> Tag Source #

Create any tag.

html :: [(Text, Text)] -> [Tag] -> Tag Source #

head' :: [(Text, Text)] -> [Tag] -> Tag Source #

body :: [(Text, Text)] -> [Tag] -> Tag Source #

div' :: [(Text, Text)] -> [Tag] -> Tag Source #

form :: [(Text, Text)] -> [Tag] -> Tag Source #

input :: [(Text, Text)] -> [Tag] -> Tag Source #

article :: [(Text, Text)] -> [Tag] -> Tag Source #

a :: [(Text, Text)] -> [Tag] -> Tag Source #

title :: [(Text, Text)] -> [Tag] -> Tag Source #

link :: [(Text, Text)] -> [Tag] -> Tag Source #

script :: [(Text, Text)] -> [Tag] -> Tag Source #

cat :: Text -> Text -> (Text, Text) Source #

Create any attribute.

(-.) :: Text -> Text -> (Text, Text) infix 0 Source #

Same as cat

Nested tag functions

alter :: Text -> (Tag -> Tag) -> Tag -> Tag Source #

Apply function on elements matching the selector.

remove :: Text -> Tag -> Tag Source #

Remove tags matching the selector. Does not remove the provided tag itself.

select :: Text -> Tag -> [Tag] Source #

Returns tags matching the selector. Obiously not too useful if you want to alter the given elements, because of Haskell's purity. See alter and remove instead.

Single tag functions

attrs :: Tag -> Attrs Source #

Returns the attributes of a tag.

attr :: Text -> Tag -> Maybe Text Source #

Returns an attribute of a tag specified by the first argument.

children :: Tag -> [Child] Source #

Returns the (direct) children of a tag.

name :: Tag -> Text Source #

Returns the name of a tag.

append :: Tag -> Tag -> Tag Source #

Insert the first argument as the last child of the second.

prepend :: Tag -> Tag -> Tag Source #

Inserts the first argument as the first child of the second.

Manipulation

addClass :: Text -> Tag -> Tag Source #

Adds the class specified by the first argument to the tag.

hasClass :: Text -> Tag -> Bool Source #

Returns true if the tag already has the given class.

Parse HTML

parseHtml :: Text -> [Tag] Source #

Turns text into tags.

Exported for testing purposes only

matches :: Text -> Tag -> Bool Source #

Just for quick and ugly testing. Tests if a (top level) tag satisfies a given selector

parseSelector :: Text -> Selector Source #