diff --git a/persistent/ChangeLog.md b/persistent/ChangeLog.md index 6bf4b8ca4..6af6798db 100644 --- a/persistent/ChangeLog.md +++ b/persistent/ChangeLog.md @@ -4,6 +4,8 @@ * [#1496](https://github.com/yesodweb/persistent/pull/1496) * Fixes name shadowing error at the generated `keyFromRecordM` function. +* [#1505](https://github.com/yesodweb/persistent/pull/1505) + * Fixes the comment line parsing rule so that accommodates paragraph breaks. ## 2.14.5.0 diff --git a/persistent/Database/Persist/Quasi/Internal.hs b/persistent/Database/Persist/Quasi/Internal.hs index 8f67e991b..aad9ec76f 100644 --- a/persistent/Database/Persist/Quasi/Internal.hs +++ b/persistent/Database/Persist/Quasi/Internal.hs @@ -53,8 +53,8 @@ module Database.Persist.Quasi.Internal import Prelude hiding (lines) import Control.Applicative (Alternative((<|>))) -import Data.Char (isDigit, isLower, isSpace, isUpper, toLower) import Control.Monad +import Data.Char (isDigit, isLower, isSpace, isUpper, toLower) import Data.List (find, foldl') import Data.List.NonEmpty (NonEmpty(..)) import qualified Data.List.NonEmpty as NEL @@ -238,7 +238,7 @@ parseIndentationAmount txt = tokenize :: Text -> [Token] tokenize t | T.null t = [] - | Just txt <- T.stripPrefix "-- | " t = [DocComment txt] + | Just txt <- T.stripPrefix "-- |" t = [DocComment (T.stripStart txt)] | "--" `T.isPrefixOf` t = [] -- Comment until the end of the line. | "#" `T.isPrefixOf` t = [] -- Also comment to the end of the line, needed for a CPP bug (#110) | T.head t == '"' = quotes (T.tail t) id diff --git a/persistent/test/Database/Persist/QuasiSpec.hs b/persistent/test/Database/Persist/QuasiSpec.hs index a987d29a6..02356ee9f 100644 --- a/persistent/test/Database/Persist/QuasiSpec.hs +++ b/persistent/test/Database/Persist/QuasiSpec.hs @@ -236,6 +236,13 @@ spec = describe "Quasi" $ do [ DocComment "this is a comment" ] ) + it "recognizes empty line" $ do + parseLine "-- |" `shouldBe` + Just + ( Line 0 + [ DocComment "" + ] + ) it "works if comment is indented" $ do parseLine " -- | comment" `shouldBe`