From bc8821fa82614c1fff0e7ff0c296b4dab6f3d6a6 Mon Sep 17 00:00:00 2001 From: "Ivan N. Veselov" Date: Thu, 2 Aug 2012 16:02:25 +0300 Subject: 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 --- src/Hakyll/Web/Page/Read.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Hakyll/Web/Page/Read.hs b/src/Hakyll/Web/Page/Read.hs index 1c3eab7..40a4cd5 100644 --- a/src/Hakyll/Web/Page/Read.hs +++ b/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) -- cgit v1.2.3