neat-interpolation 0.3.1.1 → 0.3.2
raw patch · 3 files changed
+24/−5 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- executables/APITests.hs +19/−0
- library/NeatInterpolation/Parsing.hs +4/−4
- neat-interpolation.cabal +1/−1
executables/APITests.hs view
@@ -28,3 +28,22 @@ escaped name = [text|this_could_be_${name}_long_identifier|] a = "{\n indented line\n indented line\n}" +test_dollar = do+ assertEqual+ "function(){\n function(){\n {\n indented line\n indented line\n }\n }\n return \"$b\"\n}\n"+ (template a a)+ assertEqual+ "this_could_be_$one$_long_identifier\n"+ (escaped "one")+ where+ template a b = + [text|+ function(){+ function(){+ $a+ }+ return "$$b"+ }+ |]+ escaped name = [text|this_could_be_$$${name}$$_long_identifier|]+ a = "{\n indented line\n indented line\n}"
library/NeatInterpolation/Parsing.hs view
@@ -3,7 +3,6 @@ import BasePrelude hiding (try, (<|>), many) import Text.Parsec hiding (Line) - data Line = Line {lineIndent :: Int, lineContents :: [LineContent]} deriving (Show)@@ -13,16 +12,16 @@ LineContentIdentifier [Char] deriving (Show) - parseLines :: [Char] -> Either ParseError [Line] parseLines = parse lines "NeatInterpolation.Parsing.parseLines" where lines = sepBy line newline <* eof line = Line <$> countIndent <*> many content countIndent = fmap length $ try $ lookAhead $ many $ char ' '- content = try identifier <|> contentText+ content = try escapedDollar <|> try identifier <|> contentText identifier = fmap LineContentIdentifier $ char '$' *> (try identifier' <|> between (char '{') (char '}') identifier')+ escapedDollar = fmap LineContentText $ char '$' *> count 1 (char '$') identifier' = many1 (alphaNum <|> char '\'' <|> char '_') contentText = do text <- manyTill anyChar end@@ -30,7 +29,8 @@ then fail "Empty text" else return $ LineContentText $ text where- end = + end =+ (void $ try $ lookAhead escapedDollar) <|> (void $ try $ lookAhead identifier) <|> (void $ try $ lookAhead newline) <|> eof
neat-interpolation.cabal view
@@ -1,7 +1,7 @@ name: neat-interpolation version:- 0.3.1.1+ 0.3.2 synopsis: A quasiquoter for neat and simple multiline text interpolation description: