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/Hakyll') 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 From e3b2d07756e749a4910b434226a70fc1ad5a0e63 Mon Sep 17 00:00:00 2001 From: "Ivan N. Veselov" Date: Thu, 2 Aug 2012 16:13:07 +0300 Subject: Added proper handling of windows newlines during whitespace compression of CSS files. Simpified several regexps. --- src/Hakyll/Web/CompressCss.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Hakyll') diff --git a/src/Hakyll/Web/CompressCss.hs b/src/Hakyll/Web/CompressCss.hs index 090fe10..52b5396 100644 --- a/src/Hakyll/Web/CompressCss.hs +++ b/src/Hakyll/Web/CompressCss.hs @@ -31,12 +31,12 @@ compressCss = compressSeparators compressSeparators :: String -> String compressSeparators = replaceAll "; *}" (const "}") . replaceAll " *([{};:]) *" (take 1 . dropWhile isSpace) - . replaceAll ";;*" (const ";") + . replaceAll ";+" (const ";") -- | Compresses all whitespace. -- compressWhitespace :: String -> String -compressWhitespace = replaceAll "[ \t\n][ \t\n]*" (const " ") +compressWhitespace = replaceAll "[ \t\n\r]+" (const " ") -- | Function that strips CSS comments away. -- -- cgit v1.2.3