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

Safe HaskellNone

Text.HTML.KURE

Contents

Synopsis

Reading HTML

parseHTML :: FilePath -> String -> HTMLSource

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

HTML Builders

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

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

text :: String -> HTMLSource

text creates a HTML node with text inside it.

attr :: String -> String -> AttrSource

build a single Attr. Short version of attrC.

zero :: HTMLSource

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 => Translate Context m Element a -> Translate Context m Text a -> Translate Context m Syntax a -> ([a] -> x) -> Translate Context m HTML xSource

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

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

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

elementC :: String -> Attrs -> HTML -> ElementSource

elementC builds a element from its components.

textT :: Monad m => (String -> x) -> Translate Context m Text xSource

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

textC :: String -> TextSource

textC constructs a Text from a fully unescaped string.

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

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

attrsC :: [Attr] -> AttrsSource

join attributes together.

attrT :: Monad m => (String -> String -> x) -> Translate Context m Attr xSource

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

attrC :: String -> String -> AttrSource

Create a single attribute.

Other Combinators and Observers

getAttr :: MonadCatch m => String -> Translate Context m Element StringSource

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

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

isTag checks the element for a specific element name.

getTag :: Monad m => Translate Context m Element StringSource

getTag gets the element name.

getAttrs :: Monad m => Translate Context m Element AttrsSource

getAttrs gets the attributes inside a element.

getInner :: Monad m => Translate Context m Element HTMLSource

getInner gets the HTML inside a element.

anyElementHTML :: MonadCatch m => Translate Context m Element HTML -> Rewrite Context m HTMLSource

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-translations 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 whereSource

Methods

html :: a -> HTMLSource

KURE combinators synonyms specialized to our generic type Node

injectT' :: (Monad m, Injection a g, g ~ Node) => Translate c m a gSource

projectT' :: (Monad m, Injection a g, g ~ Node) => Translate c m g aSource

extractT' :: (Monad m, Injection a g, g ~ Node) => Translate c m g b -> Translate c m a bSource

promoteT' :: (Monad m, Injection a g, g ~ Node) => Translate c m a b -> Translate c m g bSource

extractR' :: (Monad m, Injection a g, g ~ Node) => Rewrite c m g -> Rewrite c m aSource

promoteR' :: (Monad m, Injection a g, g ~ Node) => Rewrite c m a -> Rewrite c m gSource