Permalink
Browse files

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
  • Loading branch information...
sphynx committed Aug 2, 2012
1 parent b37dc1b commit bc8821fa82614c1fff0e7ff0c296b4dab6f3d6a6
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/Hakyll/Web/Page/Read.hs
@@ -4,10 +4,10 @@ module Hakyll.Web.Page.Read
( readPage
) where
-import Control.Applicative ((<$>), (<*>), (<*))
+import Control.Applicative ((<$>), (<*>), (<*), (<|>))
import qualified Data.Map as M
-import Text.Parsec.Char (alphaNum, anyChar, char, newline, oneOf, string)
+import Text.Parsec.Char (alphaNum, anyChar, char, oneOf, string)
import Text.Parsec.Combinator (choice, many1, manyTill, option, skipMany1)
import Text.Parsec.Prim (many, parse, skipMany, (<?>))
import Text.Parsec.String (Parser)
@@ -19,6 +19,11 @@ import Hakyll.Web.Page.Internal
inlineSpace :: Parser Char
inlineSpace = oneOf ['\t', ' '] <?> "space"
+-- | Parse Windows newlines as well (i.e. "\n" or "\r\n")
+newline :: Parser String
+newline = string "\n" -- Unix
+ <|> string "\r\n" -- DOS
+
-- | Parse a single metadata field
--
metadataField :: Parser (String, String)

0 comments on commit bc8821f

Please sign in to comment.