packages feed

blaze-from-html 0.3.0.0 → 0.3.1.0

raw patch · 3 files changed

+20/−10 lines, 3 files

Files

Util/BlazeFromHtml.hs view
@@ -36,7 +36,7 @@ data CombinatorType = ParentCombinator                     | LeafCombinator                     | UnknownCombinator-                    deriving (Show)+                    deriving (Eq, Show)  -- | Traverse the list of tags to produce an intermediate representation of the -- HTML tree.@@ -58,11 +58,20 @@                     _ -> makeTree variant ignore (tag' : stack) xs                  p = Parent tag' (map (first toLower') attrs) inner              in addHtml p t-    -- The closing tag must match the stack.-    TagClose tag -> if listToMaybe stack == Just (toLower' tag) || ignore-        then (Block [], xs)-        else error $  "Line " ++ show row ++ ": " ++ show tag ++ " closed but "-                   ++ show stack ++ " should be closed instead."+    -- The closing tag must match the stack. If it is a closing leaf, we can+    -- ignore it+    TagClose tag ->+        let isLeafCombinator = combinatorType variant tag == LeafCombinator+            matchesStack = listToMaybe stack == Just (toLower' tag)+        in case (isLeafCombinator, matchesStack, ignore) of+            -- It's a leaf combinator, don't care about this element+            (True, _, _)          -> makeTree variant ignore stack xs+            -- It's a parent and the stack doesn't match+            (False, False, False) -> error $+                "Line " ++ show row ++ ": " ++ show tag ++ " closed but "+                        ++ show stack ++ " should be closed instead."+            -- Stack might not match but we ignore it anyway+            (False, _, _)         -> (Block [], xs)     TagText text -> addHtml (Text text) xs     TagComment comment -> addHtml (Comment comment) xs     _ -> makeTree variant ignore stack xs
Util/GenerateHtmlCombinators.hs view
@@ -208,7 +208,7 @@     , "--"     , function        ++ " :: Html  -- ^ Inner HTML."     , spaces function ++ " -> Html  -- ^ Resulting HTML."-    , function        ++ " = Parent \"<" ++ tag+    , function        ++ " = Parent \"" ++ tag ++ "\" \"<" ++ tag                       ++ "\" \"</" ++ tag ++ ">\"" ++ modifier     , "{-# INLINE " ++ function ++ " #-}"     ]@@ -234,7 +234,7 @@     , "-- > <" ++ tag ++ " />"     , "--"     , function ++ " :: Html  -- ^ Resulting HTML."-    , function ++ " = Leaf \"<" ++ tag ++ "\" " ++ end+    , function ++ " = Leaf \"" ++ tag ++ "\" \"<" ++ tag ++ "\" " ++ end     , "{-# INLINE " ++ function ++ " #-}"     ]   where@@ -258,7 +258,8 @@     , "--"     , function        ++ " :: AttributeValue  -- ^ Attribute value."     , spaces function ++ " -> Attribute       -- ^ Resulting attribute."-    , function        ++ " = attribute \" " ++ name ++ "=\\\"\""+    , function        ++ " = attribute \"" ++ name ++ "\" \" "+                      ++ name ++ "=\\\"\""     , "{-# INLINE " ++ function ++ " #-}"     ]   where
blaze-from-html.cabal view
@@ -1,5 +1,5 @@ Name:                blaze-from-html-Version:             0.3.0.0+Version:             0.3.1.0 Synopsis:            Tool to convert HTML to BlazeHtml code. Description:         Tool that converts HTML files to Haskell code, ready to be                      used with the BlazeHtml library.