Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Be even more liberal in what to accept as section name

  • Loading branch information...
commit fe912302bb7830399dc59b94854a7a6d9dcc1737 1 parent 28c67f5
@sol authored
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
14 src/Parse.hs
@@ -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
1  src/ParseUtil.hs
@@ -10,6 +10,7 @@ module ParseUtil (
, endOfInput
, try
, string
+, char
, isHorizontalSpace
, isEndOfLine
) where
View
2  test/Arbitrary.hs
@@ -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]
Please sign in to comment.
Something went wrong with that request. Please try again.