Permalink
Browse files

Be even more liberal in what to accept as section name

  • Loading branch information...
1 parent 28c67f5 commit fe912302bb7830399dc59b94854a7a6d9dcc1737 @sol committed Dec 5, 2011
Showing with 7 additions and 10 deletions.
  1. +5 −9 src/Parse.hs
  2. +1 −0 src/ParseUtil.hs
  3. +1 −1 test/Arbitrary.hs
View
@@ -43,21 +43,17 @@ mkSection_ renderedName l = mkSection options comments blankLines renderedName
sectionHeader :: Parser (Section, Text)
sectionHeader = do
- a <- blanks
- b <- string "["
- c <- blanks
- dn <- sectionName
- e <- blanks
- f <- string "]"
- g <- blanks
+ pre <- blanks
+ name <- char '[' *> sectionName <* char ']'
+ post <- blanks
endOfLine <|> endOfInput
- return (Section dn, Text.concat [a, b, c, dn, e, f, g])
+ return (Section name, Text.concat [pre, "[", name, "]", post])
sectionName :: Parser Text
sectionName = takeWhile1 sectionClass
sectionClass :: Char -> Bool
-sectionClass c = (not . elem c) "\n\r\t []"
+sectionClass c = (not . elem c) "\n\r[]"
sectionBody :: Parser [SectionBodyLine]
sectionBody = many sectionBodyLine
View
@@ -10,6 +10,7 @@ module ParseUtil (
, endOfInput
, try
, string
+, char
, isHorizontalSpace
, isEndOfLine
) where
View
@@ -56,7 +56,7 @@ value :: Gen Text
value = resize 10 $ Text.stripStart <$> arbitraryLine
sectionHeader :: Text -> Gen Text
-sectionHeader name = concatG [blanks, pure "[", blanks, pure name, blanks, pure "]", blanks]
+sectionHeader name = concatG [blanks, pure "[", pure name, pure "]", blanks]
option :: Text -> Gen Text
option k = concatG [blanks, pure k, blanks, separator, blanks, value]

0 comments on commit fe91230

Please sign in to comment.