on master help sign in
Added support for Windows newlines in pages.

Otherwise, we are getting the following error message during page reading if some of the pages are prepared in Windows, which is somewhat confusing: hakyll: "page" (line 1, column 4): unexpected "\r" expecting "-", space or new-line

commitbc8821fa82614c1fff0e7ff0c296b4dab6f3d6a6 authorIvan N. Veselov <veselov@gmail.com> dateThu 2 Aug 2012, 16:02 (14 years ago) parentb37dc1b
1 file changed+7−2
src/Hakyll/Web/Page/Read.hs+7−2
src/Hakyll/Web/Page/Read.hs+7−2
@@ -4,10 +4,10 @@ module Hakyll.Web.Page.Read
44 ( readPage
55 ) where
66
7−import Control.Applicative ((<$>), (<*>), (<*))
7+import Control.Applicative ((<$>), (<*>), (<*), (<|>))
88import qualified Data.Map as M
99
10−import Text.Parsec.Char (alphaNum, anyChar, char, newline, oneOf, string)
10+import Text.Parsec.Char (alphaNum, anyChar, char, oneOf, string)
1111import Text.Parsec.Combinator (choice, many1, manyTill, option, skipMany1)
1212import Text.Parsec.Prim (many, parse, skipMany, (<?>))
1313import Text.Parsec.String (Parser)
@@ -19,6 +19,11 @@ import Hakyll.Web.Page.Internal
1919inlineSpace :: Parser Char
2020inlineSpace = oneOf ['\t', ' '] <?> "space"
2121
22+-- | Parse Windows newlines as well (i.e. "\n" or "\r\n")
23+newline :: Parser String
24+newline = string "\n" -- Unix
25+ <|> string "\r\n" -- DOS
26+
2227-- | Parse a single metadata field
2328--
2429metadataField :: Parser (String, String)