html-kure-0.2.1: HTML rewrite engine, using KURE.

Safe HaskellNone
LanguageHaskell98

Text.HTML.KURE

Contents

Synopsis

Reading HTML

parseHTML :: FilePath -> String -> HTML Source

parsing HTML files. If you want to unparse, use show.

HTML Builders

element :: String -> [Attr] -> HTML -> HTML Source

element is the main way of generates a element in HTML.

text :: String -> HTML Source

text creates a HTML node with text inside it.

attr :: String -> String -> Attr Source

build a single Attr. Short version of attrC.

zero :: HTML Source

zero is an empty piece of HTML, which can be used to avoid the use of the <tag/> form; for example "element "br" [] zero" will generate both an opener and closer. zero is the same as "text """.

Primitive Traversal Combinators

htmlT :: Monad m => Transform Context m Element a -> Transform Context m Text a -> Transform Context m Syntax a -> ([a] -> x) -> Transform Context m HTML x Source

htmlT take arrows that operate over elements, texts, and syntax, and returns a transformation over HTML.

elementT :: Monad m => Transform Context m Attrs a -> Transform Context m HTML b -> (String -> a -> b -> x) -> Transform Context m Element x Source

elementT take arrows that operate over attributes and (the inner) HTML, and returns a transformation over a single element.

elementC :: String -> Attrs -> HTML -> Element Source

elementC builds a element from its components.

textT :: Monad m => (String -> x) -> Transform Context m Text x Source

textT takes a Text to bits. The string is fully unescaped (a regular Haskell string)

textC :: String -> Text Source

textC constructs a Text from a fully unescaped string.

attrsT :: Monad m => Transform Context m Attr a -> ([a] -> x) -> Transform Context m Attrs x Source

attrsT promotes a transformation over Attr into a transformation over Attrs.

attrsC :: [Attr] -> Attrs Source

join attributes together.

attrT :: Monad m => (String -> String -> x) -> Transform Context m Attr x Source

promote a function over an attributes components into a transformation over Attr.

attrC :: String -> String -> Attr Source

Create a single attribute.

Other Combinators and Observers

getAttr :: MonadCatch m => String -> Transform Context m Element String Source

getAttr gets the attributes of a specific attribute of a element.

isTag :: Monad m => String -> Transform Context m Element () Source

isTag checks the element for a specific element name.

getTag :: Monad m => Transform Context m Element String Source

getTag gets the element name.

getAttrs :: Monad m => Transform Context m Element Attrs Source

getAttrs gets the attributes inside a element.

getInner :: Monad m => Transform Context m Element HTML Source

getInner gets the HTML inside a element.

anyElementHTML :: MonadCatch m => Transform Context m Element HTML -> Rewrite Context m HTML Source

lifts mapping of Element to HTML over a single level of HTML sub-nodes. anyElementHTML has the property ''anyElementHTML (arr html) = idR''.

This is successful only if any of the sub-transformations are successful.

unconcatHTML :: HTML -> [HTML] Source

Flatten into singleton HTMLs. The opposite of mconcat.

Types and Classes

data HTML Source

The Principal type in DSL. Use show to get the String rendition of this type. HTML is concatenated using <>, the Monoid mappend.

data Element Source

HTML element with tag and attrs

data Text Source

Text (may include escaped text internally)

data Attrs Source

Attributes for a element

data Attr Source

Single attribute

data Syntax Source

XML/HTML syntax, like <? or <!, or our zero-width space zero.

newtype Context Source

Context contains all the containing elements in an inside to outside order

Constructors

Context [Element] 

data Node Source

Our universal node type. Only used during generic tree walking and traversals.

class Html a where Source

Methods

html :: a -> HTML Source

KURE combinators synonyms specialized to our universe type Node

extractT' :: (Monad m, Injection a Node) => Transform c m Node b -> Transform c m a b Source

promoteT' :: (Monad m, Injection a Node) => Transform c m a b -> Transform c m Node b Source