Permalink
Browse files

Merge pull request #75 from sphynx/master

Added Windows newlines (\r\n) support to the page parser and CSS compressor
  • Loading branch information...
2 parents 763eeb9 + e3b2d07 commit f85cee026f44385c018c673f5c75122306a31ee0 @jaspervdj jaspervdj committed Aug 2, 2012
Showing with 9 additions and 4 deletions.
  1. +2 −2 src/Hakyll/Web/CompressCss.hs
  2. +7 −2 src/Hakyll/Web/Page/Read.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.
--
@@ -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 f85cee0

Please sign in to comment.