From ecfb61fd727ce6886683000584da112fab156d56 Mon Sep 17 00:00:00 2001 From: Dylan Simon Date: Thu, 13 Sep 2018 13:08:29 -0400 Subject: [PATCH] Add hamlet operator parsing from shakespeare#223 Corresponds to https://github.com/yesodweb/shakespeare/pull/223 Bump xml-hamlet to 0.5.1 and update stackage build --- stack.yaml | 9 +-------- xml-hamlet/Text/Hamlet/XMLParse.hs | 8 ++++---- xml-hamlet/xml-hamlet.cabal | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/stack.yaml b/stack.yaml index 17d4894b..93477631 100644 --- a/stack.yaml +++ b/stack.yaml @@ -2,11 +2,4 @@ packages: - xml-conduit/ - xml-hamlet/ - html-conduit/ -resolver: lts-10.3 -extra-deps: -- conduit-1.3.0 -- conduit-extra-1.3.0 -- resourcet-1.2.0 -- mono-traversable-1.0.8.1 -- unliftio-core-0.1.1.0 -- typed-process-0.2.1.0 +resolver: lts-11.22 diff --git a/xml-hamlet/Text/Hamlet/XMLParse.hs b/xml-hamlet/Text/Hamlet/XMLParse.hs index afab6e65..c0630f3c 100644 --- a/xml-hamlet/Text/Hamlet/XMLParse.hs +++ b/xml-hamlet/Text/Hamlet/XMLParse.hs @@ -1,6 +1,5 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE CPP #-} module Text.Hamlet.XMLParse ( Result (..) , Content (..) @@ -15,7 +14,7 @@ module Text.Hamlet.XMLParse import Text.Shakespeare.Base import Control.Applicative ((<$>), Applicative (..)) import Control.Monad -import Data.Char (isUpper) +import Data.Char (GeneralCategory(..), generalCategory, isUpper) import Data.Data import Text.ParserCombinators.Parsec hiding (Line) @@ -223,7 +222,8 @@ parseLine = do 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" @@ -247,7 +247,7 @@ parseLine = do 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 diff --git a/xml-hamlet/xml-hamlet.cabal b/xml-hamlet/xml-hamlet.cabal index 012073d2..e9774ee4 100644 --- a/xml-hamlet/xml-hamlet.cabal +++ b/xml-hamlet/xml-hamlet.cabal @@ -1,5 +1,5 @@ Name: xml-hamlet -Version: 0.5.0 +Version: 0.5.1 Synopsis: Hamlet-style quasiquoter for XML content Homepage: http://www.yesodweb.com/ License: BSD3