moe 2009.8.23 → 2009.8.26
raw patch · 8 files changed
+177/−131 lines, 8 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Text.HTML.Moe.Attribute: action :: String -> Attribute
+ Text.HTML.Moe.Attribute: method :: String -> Attribute
+ Text.HTML.Moe.Attribute: size :: String -> Attribute
+ Text.HTML.Moe.Element: form :: MoeCombinator
+ Text.HTML.Moe.Element: form' :: MoeCombinator'
+ Text.HTML.Moe.Element: input :: MoeCombinator
+ Text.HTML.Moe.Element: input' :: MoeCombinator'
+ Text.HTML.Moe.Element: label :: MoeCombinator
+ Text.HTML.Moe.Element: label' :: MoeCombinator'
+ Text.HTML.Moe.Element: option :: MoeCombinator
+ Text.HTML.Moe.Element: option' :: MoeCombinator'
+ Text.HTML.Moe.Element: select :: MoeCombinator
+ Text.HTML.Moe.Element: select' :: MoeCombinator'
- Text.HTML.Moe.Element: e :: String -> MoeCombinator'
+ Text.HTML.Moe.Element: e :: String -> MoeCombinator
- Text.HTML.Moe.Element: element :: (String -> MoeCombinator') -> (String -> MoeCombinator)
+ Text.HTML.Moe.Element: element :: (String -> MoeCombinator) -> (String -> MoeCombinator')
- Text.HTML.Moe.Element: element' :: String -> MoeCombinator'
+ Text.HTML.Moe.Element: element' :: String -> MoeCombinator
- Text.HTML.Moe.Type: type MoeCombinator = MoeUnit -> MoeUnit
+ Text.HTML.Moe.Type: type MoeCombinator = [Attribute] -> MoeUnit -> MoeUnit
- Text.HTML.Moe.Type: type MoeCombinator' = [Attribute] -> MoeUnit -> MoeUnit
+ Text.HTML.Moe.Type: type MoeCombinator' = MoeUnit -> MoeUnit
Files
- changelog.md +9/−0
- moe.cabal +2/−2
- readme.md +10/−12
- src/Text/HTML/Moe.hs +15/−3
- src/Text/HTML/Moe/Attribute.hs +7/−1
- src/Text/HTML/Moe/Element.hs +124/−103
- src/Text/HTML/Moe/Type.hs +2/−2
- src/test.hs +8/−8
changelog.md view
@@ -1,3 +1,12 @@+2009.8.25+---------++### Feature++* revert element syntax+* internal escape html function+* escape both attribute and element body+ 2009.8.24 ---------
moe.cabal view
@@ -1,7 +1,7 @@ Name: moe-Version: 2009.8.23+Version: 2009.8.26 Build-type: Simple-Synopsis: html combinator with style+Synopsis: html with style Description: a purely functional html combinator with a clean syntax
readme.md view
@@ -1,6 +1,4 @@-# Moe--html combinator with style+# Moe: html with style # Example @@ -8,21 +6,21 @@ -- test.hs - import Prelude hiding ((/), (-), head, (>), (.))+ import Prelude hiding ((/), (-), head, (>), (.), div) import MPS.Light ((-)) import Text.HTML.Moe test_page :: String test_page = render -- html - do- head - do- meta'+ html' - do+ head' - do+ meta [http_equiv "Content-Type", content "text/html; charset-utf-8"] (/)- title - str "my title"- link' [rel "icon", _type "image/png", href "panda_icon.png"] (/)-- body - do- div' [_class "container"] - do+ title' - str "my title"+ link [rel "icon", _type "image/png", href "panda_icon.png"] (/)+ + body' - do+ div [_class "container"] - do str "hello world" main :: IO ()
src/Text/HTML/Moe.hs view
@@ -12,7 +12,6 @@ import Control.Monad.Writer (tell, execWriter) import Prelude hiding ((/), (-), head, (>), (.)) import MPS.Light ((-), (>), (.), join, times)-import MPS.Heavy import Text.HTML.Moe.Type hiding (name, value) import qualified Text.HTML.Moe.Type as T import Text.HTML.Moe.Element@@ -32,7 +31,7 @@ render_element' n (Data x) = execWriter - do tell - (n * indent_space).times ' '- tell - escape_xml x+ tell - escape - x tell - "\n" render_element' n x = execWriter - do@@ -57,4 +56,17 @@ render_element = render_element' 0 render_attribute :: Attribute -> String-render_attribute x = x.key ++ "=" ++ "\"" ++ x.T.value ++ "\""+render_attribute x = x.key ++ "=" ++ "\"" ++ x.T.value.escape ++ "\""++escape :: String -> String+escape = escape_html++escape_html :: String -> String+escape_html = concatMap fixChar+ where+ fixChar '&' = "&"+ fixChar '<' = "<"+ fixChar '>' = ">"+ fixChar '\'' = "'"+ fixChar '"' = """+ fixChar x = [x]
src/Text/HTML/Moe/Attribute.hs view
@@ -12,6 +12,7 @@ _style :: String -> Attribute _title :: String -> Attribute _type :: String -> Attribute+action :: String -> Attribute align :: String -> Attribute alt :: String -> Attribute bgcolor :: String -> Attribute@@ -26,11 +27,13 @@ lang :: String -> Attribute language :: String -> Attribute media :: String -> Attribute+method :: String -> Attribute name :: String -> Attribute quality :: String -> Attribute rel :: String -> Attribute rowspan :: String -> Attribute src :: String -> Attribute+size :: String -> Attribute target :: String -> Attribute valign :: String -> Attribute value :: String -> Attribute@@ -44,6 +47,7 @@ _style = attr "style" _title = attr "title" _type = attr "type"+action = attr "action" align = attr "align" alt = attr "alt" bgcolor = attr "bgcolor"@@ -58,16 +62,18 @@ lang = attr "lang" language = attr "language" media = attr "media"+method = attr "method" name = attr "name" quality = attr "quality" rel = attr "rel" rowspan = attr "rowspan" src = attr "src"+size = attr "size" target = attr "target" valign = attr "valign" value = attr "value" width = attr "width"-xml_lang = attr "xml_lang"+xml_lang = attr "xml:lang" xmlns = attr "xmlns"
src/Text/HTML/Moe/Element.hs view
@@ -3,9 +3,9 @@ import Text.HTML.Moe.Type import Data.Default import Control.Monad.Writer-import Prelude hiding (id, span, div)+import Prelude hiding (id, span, div, head) -element' :: String -> MoeCombinator'+element' :: String -> MoeCombinator element' x xs u = tell [ def {@@ -15,12 +15,51 @@ } ] -element :: (String -> MoeCombinator') -> (String -> MoeCombinator)+element :: (String -> MoeCombinator) -> (String -> MoeCombinator') element x = flip x [] -e :: String -> MoeCombinator'+e :: String -> MoeCombinator e = element' +a :: MoeCombinator+body :: MoeCombinator+br :: MoeCombinator+colgroup :: MoeCombinator+col :: MoeCombinator+div :: MoeCombinator+form :: MoeCombinator+embed :: MoeCombinator+h1 :: MoeCombinator+h2 :: MoeCombinator+h3 :: MoeCombinator+head :: MoeCombinator+html :: MoeCombinator+img :: MoeCombinator+input :: MoeCombinator+label :: MoeCombinator+li :: MoeCombinator+link :: MoeCombinator+meta :: MoeCombinator+object :: MoeCombinator+ol :: MoeCombinator+param :: MoeCombinator+ul :: MoeCombinator+dl :: MoeCombinator+dt :: MoeCombinator+dd :: MoeCombinator+option :: MoeCombinator+p :: MoeCombinator+pre :: MoeCombinator+select :: MoeCombinator+script :: MoeCombinator+span :: MoeCombinator+style :: MoeCombinator+table :: MoeCombinator+td :: MoeCombinator+th :: MoeCombinator+title :: MoeCombinator+tr :: MoeCombinator+ a' :: MoeCombinator' body' :: MoeCombinator' br' :: MoeCombinator'@@ -28,12 +67,15 @@ col' :: MoeCombinator' div' :: MoeCombinator' embed' :: MoeCombinator'+form' :: MoeCombinator' h1' :: MoeCombinator' h2' :: MoeCombinator' h3' :: MoeCombinator' head' :: MoeCombinator' html' :: MoeCombinator' img' :: MoeCombinator'+input' :: MoeCombinator'+label' :: MoeCombinator' li' :: MoeCombinator' link' :: MoeCombinator' meta' :: MoeCombinator'@@ -44,8 +86,10 @@ dl' :: MoeCombinator' dt' :: MoeCombinator' dd' :: MoeCombinator'+option' :: MoeCombinator' p' :: MoeCombinator' pre' :: MoeCombinator'+select' :: MoeCombinator' script' :: MoeCombinator' span' :: MoeCombinator' style' :: MoeCombinator'@@ -56,110 +100,87 @@ tr' :: MoeCombinator' -a' = e "a"-body' = e "body"-br' = e "br"-colgroup' = e "colgroup"-col' = e "col"-div' = e "div"-embed' = e "embed"-h1' = e "h1"-h2' = e "h2"-h3' = e "h3"-head' = e "head"-html' = e "html"-img' = e "img"-li' = e "li"-link' = e "link"-meta' = e "meta"-object' = e "object"-ol' = e "ol"-param' = e "param"-ul' = e "ul"-dl' = e "dl"-dt' = e "dt"-dd' = e "dd"-p' = e "p"-pre' = e "pre"-script' = e "script"-span' = e "span"-style' = e "style"-table' = e "table"-td' = e "td"-th' = e "th"-title' = e "title"-tr' = e "tr"+a = e "a"+body = e "body"+br = e "br"+colgroup = e "colgroup"+col = e "col"+div = e "div"+embed = e "embed"+form = e "form"+h1 = e "h1"+h2 = e "h2"+h3 = e "h3"+head = e "head"+html = e "html"+img = e "img"+input = e "input"+label = e "label"+li = e "li"+link = e "link"+meta = e "meta"+object = e "object"+ol = e "ol"+param = e "param"+ul = e "ul"+dl = e "dl"+dt = e "dt"+dd = e "dd"+option = e "option"+p = e "p"+pre = e "pre"+select = e "select"+script = e "script"+span = e "span"+style = e "style"+table = e "table"+td = e "td"+th = e "th"+title = e "title"+tr = e "tr" -a :: MoeCombinator-body :: MoeCombinator-br :: MoeCombinator-colgroup :: MoeCombinator-col :: MoeCombinator-div :: MoeCombinator-embed :: MoeCombinator-h1 :: MoeCombinator-h2 :: MoeCombinator-h3 :: MoeCombinator-head :: MoeCombinator-html :: MoeCombinator-img :: MoeCombinator-li :: MoeCombinator-link :: MoeCombinator-meta :: MoeCombinator-object :: MoeCombinator-ol :: MoeCombinator-param :: MoeCombinator-ul :: MoeCombinator-dl :: MoeCombinator-dt :: MoeCombinator-dd :: MoeCombinator-p :: MoeCombinator-pre :: MoeCombinator-script :: MoeCombinator-span :: MoeCombinator-style :: MoeCombinator-table :: MoeCombinator-td :: MoeCombinator-th :: MoeCombinator-title :: MoeCombinator-tr :: MoeCombinator -a = a' []-body = body' []-br = br' []-colgroup = colgroup' []-col = col' []-div = div' []-embed = embed' []-h1 = h1' []-h2 = h2' []-h3 = h3' []-head = head' []-html = html' []-img = img' []-li = li' []-link = link' []-meta = meta' []-object = object' []-ol = ol' []-param = param' []-ul = ul' []-dl = dl' []-dt = dt' []-dd = dd' []-p = p' []-pre = pre' []-script = script' []-span = span' []-style = style' []-table = table' []-td = td' []-th = th' []-title = title' []-tr = tr' []+a' = a []+body' = body []+br' = br []+colgroup' = colgroup []+col' = col []+div' = div []+embed' = embed []+form' = form []+h1' = h1 []+h2' = h2 []+h3' = h3 []+head' = head []+html' = html []+img' = img []+input' = input []+label' = label []+li' = li []+link' = link []+meta' = meta []+object' = object []+ol' = ol []+param' = param []+ul' = ul []+dl' = dl []+dt' = dt []+dd' = dd []+option' = option []+p' = p []+pre' = pre []+select' = select []+script' = script []+span' = span []+style' = style []+table' = table []+td' = td []+th' = th []+title' = title []+tr' = tr [] str :: String -> MoeUnit raw :: String -> MoeUnit
src/Text/HTML/Moe/Type.hs view
@@ -30,5 +30,5 @@ type MoeUnitT a = Writer [Element] a type MoeUnit = MoeUnitT () -type MoeCombinator' = [Attribute] -> MoeUnit -> MoeUnit-type MoeCombinator = MoeUnit -> MoeUnit+type MoeCombinator = [Attribute] -> MoeUnit -> MoeUnit+type MoeCombinator' = MoeUnit -> MoeUnit
src/test.hs view
@@ -1,18 +1,18 @@-import Prelude hiding ((/), (-), head, (>), (.))+import Prelude hiding ((/), (-), head, (>), (.), div) import MPS.Light ((-)) import Text.HTML.Moe test_page :: String test_page = render -- html - do- head - do- meta'+ html' - do+ head' - do+ meta [http_equiv "Content-Type", content "text/html; charset-utf-8"] (/)- title - str "my title"- link' [rel "icon", _type "image/png", href "panda_icon.png"] (/)+ title' - str "my title"+ link [rel "icon", _type "image/png", href "panda_icon.png"] (/) - body - do- div' [_class "container"] - do+ body' - do+ div [_class "container"] - do str "hello world" main :: IO ()