packages feed

shakespeare 2.0.16 → 2.0.17

raw patch · 5 files changed

+25/−5 lines, 5 files

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+### 2.0.17++* Fix parse pattern-match with operator constructor [#222](https://github.com/yesodweb/shakespeare/issues/222)+ ### 2.0.16  * Updated `encodeToTextBuilder` also escapes single quotes [#221](https://github.com/yesodweb/shakespeare/pull/221)
Text/Hamlet/Parse.hs view
@@ -23,7 +23,7 @@ import Control.Applicative ((<$>), Applicative (..)) import Control.Monad import Control.Arrow-import Data.Char (isUpper)+import Data.Char (GeneralCategory(..), generalCategory, isUpper) import Data.Data import Text.ParserCombinators.Parsec hiding (Line) import Data.Set (Set)@@ -306,7 +306,8 @@      ident :: Parser Ident     ident = do-      i <- many1 (alphaNum <|> char '_' <|> char '\'')+      i <- many1 (alphaNum <|> char '_' <|> char '\'') <|>+           (char '(' *> many1 (satisfy (\c -> generalCategory c == OtherPunctuation)) <* char ')')       white       return (Ident i)      <?> "identifier"@@ -330,7 +331,7 @@     isVariable (Ident (x:_)) = not (isUpper x)     isVariable (Ident []) = error "isVariable: bad identifier" -    isConstructor (Ident (x:_)) = isUpper x+    isConstructor (Ident (x:_)) = isUpper x || generalCategory x == OtherPunctuation     isConstructor (Ident []) = error "isConstructor: bad identifier"      identPattern :: Parser Binding
shakespeare.cabal view
@@ -1,5 +1,5 @@ name:            shakespeare-version:         2.0.16+version:         2.0.17 license:         MIT license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>
test/Text/HamletSpec.hs view
@@ -297,6 +297,18 @@     $forall num <- [1, 2, 3]
         <li>#{show num}
 |]
+    it "pattern-match list: maybe" $ do
+      let example :: [Int]
+          example = [1, 2, 3]
+      helper "<ul><li>1</li><li>2</li><li>3</li></ul>" [hamlet|
+$newline never
+<ul>
+    $case example
+        $of (:) x xs
+            <li>#{x}
+            $forall y <- xs
+                <li>#{y}
+|]
     it "infix operators" $
       helper "5" [hamlet|#{show $ (4 + 5) - (2 + 2)}|]
     it "infix operators with parens" $
test/Text/Shakespeare/TextSpec.hs view
@@ -8,6 +8,7 @@ import Prelude hiding (reverse)
 import Text.Shakespeare.Text
 import Data.List (intercalate)
+import qualified Data.Text as T
 import qualified Data.Text.Lazy as TL
 import qualified Data.List
 import qualified Data.List as L
@@ -112,7 +113,9 @@                                      |]
 
 simpT :: String -> TL.Text -> Assertion
-simpT a b = pack a @=? TL.toStrict b
+simpT a b = nocrlf (pack a) @=? nocrlf (TL.toStrict b)
+  where
+    nocrlf = T.replace (pack "\r\n") (pack "\n")
 
 
 data Url = Home | Sub SubUrl