Skip to content

Commit 05fa110

Browse files
author
Geobert Quach
committed
1 parent dba2ad0 commit 05fa110

File tree

6 files changed

+20
-0
lines changed

6 files changed

+20
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text eol=lf

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ serde = "1.0"
4343
serde_yaml = "0.7"
4444
serde_json = "1.0"
4545
toml = "0.4.0"
46+
normalize-line-endings = "0.2.2"
4647

4748
[dependencies.sass-rs]
4849
version = "0.2.0"

src/document.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::collections::HashMap;
22
use std::collections::hash_map::Entry;
33
use std::default::Default;
44
use std::path::{Path, PathBuf};
5+
use std::iter::FromIterator;
56

67
use chrono::{Datelike, Timelike};
78
use itertools;
@@ -12,6 +13,7 @@ use pulldown_cmark as cmark;
1213
use regex::Regex;
1314
use rss;
1415
use serde_yaml;
16+
use normalize_line_endings::normalized;
1517

1618
use error::*;
1719
use cobalt_model::files;
@@ -198,6 +200,7 @@ impl Document {
198200
-> Result<Document> {
199201
trace!("Parsing {:?}", rel_path);
200202
let content = files::read_file(src_path)?;
203+
let content = String::from_iter(normalized(content.chars()));
201204
let builder = legacy_model::DocumentBuilder::parse(&content)?;
202205
let builder: cobalt_model::DocumentBuilder<cobalt_model::FrontmatterBuilder> = builder
203206
.into();

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ extern crate lazy_static;
8484
#[macro_use]
8585
extern crate serde;
8686

87+
extern crate normalize_line_endings;
88+
8789
pub use cobalt::build;
8890
pub use error::Error;
8991
pub use cobalt_model::Config;

tests/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@ extern crate cobalt;
55
extern crate error_chain;
66
extern crate tempdir;
77
extern crate walkdir;
8+
extern crate normalize_line_endings;
89

910
use std::error::Error;
1011
use std::fs::{self, File};
1112
use std::io::Read;
1213
use std::path::{Path, PathBuf};
14+
use std::iter::FromIterator;
1315

1416
use error_chain::ChainedError;
1517
use tempdir::TempDir;
1618
use walkdir::WalkDir;
19+
use normalize_line_endings::normalized;
1720

1821
macro_rules! assert_contains {
1922
($haystack: expr, $needle: expr) => {
@@ -50,6 +53,9 @@ fn assert_dirs_eq(expected: &Path, actual: &Path) {
5053
.read_to_string(&mut created)
5154
.expect("Could not read to string");
5255

56+
let original = String::from_iter(normalized(original.chars()));
57+
let created = String::from_iter(normalized(created.chars()));
58+
5359
assert_diff!(&original, &created, " ", 0);
5460
}
5561

0 commit comments

Comments
 (0)