summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2012-08-02 07:17:21 -0700
committerJasper Van der Jeugt <jaspervdj@gmail.com>2012-08-02 07:17:21 -0700
commitf85cee026f44385c018c673f5c75122306a31ee0 (patch)
treeae7f2f318e92c4b83cbffda76ef91a89341bdfa7
parent763eeb9c9d98591ae0815484e6a60d93eac1439c (diff)
parente3b2d07756e749a4910b434226a70fc1ad5a0e63 (diff)
downloadhakyll-f85cee026f44385c018c673f5c75122306a31ee0.tar.gz
Merge pull request #75 from sphynx/master
Added Windows newlines (\r\n) support to the page parser and CSS compressor
-rw-r--r--src/Hakyll/Web/CompressCss.hs4
-rw-r--r--src/Hakyll/Web/Page/Read.hs9
2 files changed, 9 insertions, 4 deletions
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.
--
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)