Skip to content

Commit

Permalink
Filter out CRs, so everything still works on Windows.
Browse files Browse the repository at this point in the history
Closes #8.
  • Loading branch information
jgm committed Mar 1, 2010
1 parent b5ded41 commit ca8d307
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Yst/CSV.hs
Expand Up @@ -30,7 +30,7 @@ import System.IO.UTF8
#endif

readCSVFile :: FilePath -> IO Node
readCSVFile f = catch (readFile f >>= return . csvToNode . parseCSV' f . stripBlanks)
readCSVFile f = catch (readFile f >>= return . csvToNode . parseCSV' f . stripBlanks . filter (/='\r'))
(\e -> errorExit 11 ("Error parsing " ++ f ++ ": " ++ show e) >> return NNil)

parseCSV' :: FilePath -> String -> CSV
Expand Down
2 changes: 1 addition & 1 deletion Yst/Render.hs
Expand Up @@ -110,7 +110,7 @@ renderPage site page = do
todaysDate <- liftM utctDay getCurrentTime
rawContents <-
case sourceFile page of
SourceFile sf -> readFile (srcDir </> sf)
SourceFile sf -> liftM (filter (/='\r')) $ readFile (srcDir </> sf)
TemplateFile tf -> do
templ <- getTemplate tf g
return $ render (setManyAttrib attrs templ)
Expand Down
4 changes: 2 additions & 2 deletions Yst/Yaml.hs
Expand Up @@ -25,7 +25,7 @@ import qualified Data.Yaml.Syck (unpackBuf, packBuf)
import Data.Time
import System.Locale (defaultTimeLocale)
import Codec.Binary.UTF8.String (encodeString, decodeString)
import qualified Data.ByteString.Char8 as B (ByteString, readFile)
import qualified Data.ByteString.Char8 as B (ByteString, readFile, filter)

-- Note: Syck isn't unicode aware, so we use parseYamlBytes and do our
-- own encoding and decoding.
Expand All @@ -39,7 +39,7 @@ packBuf :: String -> Buf
packBuf = Data.Yaml.Syck.packBuf . encodeString

readYamlFile :: FilePath -> IO Node
readYamlFile f = catch (B.readFile f >>= parseYamlBytes >>= return . yamlNodeToNode)
readYamlFile f = catch (B.readFile f >>= parseYamlBytes . B.filter (/='\r') >>= return . yamlNodeToNode)
(\e -> errorExit 11 ("Error parsing " ++ f ++ ": " ++ show e) >> return NNil)

yamlNodeToNode :: YamlNode -> Node
Expand Down

0 comments on commit ca8d307

Please sign in to comment.