moe 2009.9.2 → 2009.9.16
raw patch · 10 files changed
+110/−57 lines, 10 files
Files
- changelog.md +15/−0
- moe.cabal +1/−1
- readme.md +7/−11
- src/Text/HTML/Moe.hs +28/−15
- src/Text/HTML/Moe/Attribute.hs +4/−0
- src/Text/HTML/Moe/DSL/Kawaii.hs +4/−1
- src/Text/HTML/Moe/DSL/Markdown.hs +2/−2
- src/Text/HTML/Moe/Element.hs +35/−23
- src/Text/HTML/Moe/Type.hs +12/−1
- src/test.hs +2/−3
changelog.md view
@@ -1,3 +1,18 @@+2009.9.16+---------++### Feature++* Thanks to eagletmt, self closing tags are possilbe++ * input+ * br+ * hr+ * meta+ * link++ are now self closing tags.+ 2009.9.2 --------
moe.cabal view
@@ -1,5 +1,5 @@ Name: moe-Version: 2009.9.2+Version: 2009.9.16 Build-type: Simple Synopsis: html with style Description:
readme.md view
@@ -14,17 +14,17 @@ test_page = render - html' - do head' - do- meta- [http_equiv "Content-Type", content "text/html; charset-utf-8"] (/)+ 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"] (/)- + link [rel "icon", _type "image/png", href "panda_icon.png"]+ body' - do div [_class "container"] - do str "hello world"- + main :: IO () main = putStrLn test_page+ install and run @@ -37,13 +37,11 @@ <html> <head>- <meta http-equiv="Content-Type" content="text/html; charset-utf-8">- </meta>+ <meta http-equiv="Content-Type" content="text/html; charset-utf-8"/> <title> my title </title>- <link rel="icon" type="image/png" href="panda_icon.png">- </link>+ <link rel="icon" type="image/png" href="panda_icon.png"/> </head> <body> <div class="container">@@ -51,6 +49,4 @@ </div> </body> </html>--
src/Text/HTML/Moe.hs view
@@ -49,23 +49,36 @@ render_element' n (Prim x) = _indent n + x + new_line render_element' n (Data x) = _indent n + x + new_line -render_element' n x = - [ _indent n- , "<".pack- , x.T.name- , x.attributes.map render_attribute. join_attribute- , ">".pack- , new_line- , x.elements.map (render_element' (n P.+ 1)) .concat- , _indent n- , "</".pack- , x.T.name- , ">".pack- , new_line- ]- .concat+render_element' n x + | x.self_close =+ [ _indent n+ , "<".pack+ , x.T.name+ , x.attributes.map render_attribute. join_attribute+ , " />".pack+ , new_line+ ]+ .concat+ + | otherwise = + [ _indent n+ , "<".pack+ , x.T.name+ , x.attributes.map render_attribute. join_attribute+ , ">".pack+ , new_line+ , x.elements.map (render_element' (n P.+ 1)) .concat+ , _indent n+ , "</".pack+ , x.T.name+ , ">".pack+ , new_line+ ]+ .concat+ where join_attribute xs = xs.map (pack " " `append`) .concat+ render_element :: Element -> Internal
src/Text/HTML/Moe/Attribute.hs view
@@ -22,6 +22,7 @@ border :: String -> Attribute classid :: String -> Attribute colspan :: String -> Attribute+cols :: String -> Attribute content :: String -> Attribute height :: String -> Attribute href :: String -> Attribute@@ -35,6 +36,7 @@ quality :: String -> Attribute rel :: String -> Attribute rowspan :: String -> Attribute+rows :: String -> Attribute selected :: String -> Attribute src :: String -> Attribute size :: String -> Attribute@@ -58,6 +60,7 @@ border = attr "border" classid = attr "classid" colspan = attr "colspan"+cols = attr "cols" content = attr "content" height = attr "height" href = attr "href"@@ -71,6 +74,7 @@ quality = attr "quality" rel = attr "rel" rowspan = attr "rowspan"+rows = attr "rows" selected = attr "selected" src = attr "src" size = attr "size"
src/Text/HTML/Moe/DSL/Kawaii.hs view
@@ -10,7 +10,10 @@ c x = div [_class x] css :: String -> MoeUnit-css x = link [rel "stylesheet", _type "text/css", href x] (/)+css x = link [rel "stylesheet", _type "text/css", href x]++js :: String -> MoeUnit+js x = script [_type "text/javascript", src x] (/) (~>) :: String -> String -> MoeUnit (~>) = (<>)
src/Text/HTML/Moe/DSL/Markdown.hs view
@@ -56,6 +56,6 @@ -- __ = r strong' o = r li' block = pre' . code' . _pre-(***) = hr' (/)-(!) x y = img [src y, alt x] (/)+(***) = hr'+(!) x y = img [src y, alt x] (<>) x y = a [href y] - str x
src/Text/HTML/Moe/Element.hs view
@@ -9,8 +9,8 @@ import Data.DList (singleton, toList) -element' :: String -> MoeCombinator-element' x xs u = tell - singleton - +element :: String -> MoeCombinator+element x xs u = tell - singleton - def { name = pack - escape x@@ -19,10 +19,10 @@ } e :: String -> MoeCombinator-e = element'+e = element -element :: (String -> MoeCombinator) -> (String -> MoeCombinator')-element x = flip x []+element' :: (String -> MoeCombinator) -> (String -> MoeCombinator')+element' x = flip x [] no_indent_element :: String -> MoeCombinator no_indent_element x xs u = tell - singleton -@@ -37,9 +37,21 @@ ne :: String -> MoeCombinator ne = no_indent_element +self_close_element :: String -> LightCombinator+self_close_element x xs = tell - singleton - + def+ {+ name = pack - escape x+ , attributes = xs+ , self_close = True+ }++sc :: String -> LightCombinator+sc = self_close_element+ a :: MoeCombinator body :: MoeCombinator-br :: MoeCombinator+br :: LightCombinator blockquote :: MoeCombinator code :: MoeCombinator colgroup :: MoeCombinator@@ -56,13 +68,13 @@ h6 :: MoeCombinator head :: MoeCombinator html :: MoeCombinator-hr :: MoeCombinator-img :: MoeCombinator-input :: MoeCombinator+hr :: LightCombinator+img :: LightCombinator+input :: LightCombinator label :: MoeCombinator li :: MoeCombinator-link :: MoeCombinator-meta :: MoeCombinator+link :: LightCombinator+meta :: LightCombinator object :: MoeCombinator ol :: MoeCombinator param :: MoeCombinator@@ -87,7 +99,7 @@ a' :: MoeCombinator' body' :: MoeCombinator'-br' :: MoeCombinator'+br' :: LightCombinator' blockquote' :: MoeCombinator' code' :: MoeCombinator' colgroup' :: MoeCombinator'@@ -104,13 +116,13 @@ h6' :: MoeCombinator' head' :: MoeCombinator' html' :: MoeCombinator'-hr' :: MoeCombinator'-img' :: MoeCombinator'-input' :: MoeCombinator'+hr' :: LightCombinator'+img' :: LightCombinator'+input' :: LightCombinator' label' :: MoeCombinator' li' :: MoeCombinator'-link' :: MoeCombinator'-meta' :: MoeCombinator'+link' :: LightCombinator'+meta' :: LightCombinator' object' :: MoeCombinator' ol' :: MoeCombinator' param' :: MoeCombinator'@@ -136,7 +148,7 @@ a = e "a" body = e "body"-br = e "br"+br = sc "br" blockquote = e "blockquote" code = e "code" colgroup = e "colgroup"@@ -153,13 +165,13 @@ h6 = e "h6" head = e "head" html = e "html"-hr = e "hr"-img = e "img"-input = e "input"+hr = sc "hr"+img = sc "img"+input = sc "input" label = e "label" li = e "li"-link = e "link"-meta = e "meta"+link = sc "link"+meta = sc "meta" object = e "object" ol = e "ol" param = e "param"
src/Text/HTML/Moe/Type.hs view
@@ -12,6 +12,7 @@ , attributes :: [Attribute] , elements :: [Element] , indent :: Bool+ , self_close :: Bool } | Raw Internal -- no escape, no indent | Pre Internal -- escape, no indent@@ -20,7 +21,14 @@ deriving (Show) instance Default Element where- def = Element none def def True+ def = Element + {+ name = none+ , attributes = def+ , elements = def+ , indent = True+ , self_close = False+ } data Attribute = Attribute {@@ -37,3 +45,6 @@ type MoeCombinator = [Attribute] -> MoeUnit -> MoeUnit type MoeCombinator' = MoeUnit -> MoeUnit++type LightCombinator = [Attribute] -> MoeUnit+type LightCombinator' = MoeUnit
src/test.hs view
@@ -6,10 +6,9 @@ test_page = render - html' - do head' - do- meta- [http_equiv "Content-Type", content "text/html; charset-utf-8"] (/)+ 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"] (/)+ link [rel "icon", _type "image/png", href "panda_icon.png"] body' - do div [_class "container"] - do