diff --git a/CHANGELOG.md b/CHANGELOG.md index c506569..3ec47fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ sections up to the index to be used with the `get_section` Tera function - Ensure content directory exists before rendering aliases - Do not include drafts in pagination - Pages filenames starting by a date will now use that date as page date if there isn't one defined in frontmatter +- Accept markdown files starting with BOM ## 0.4.2 (2018-09-03) diff --git a/components/utils/src/fs.rs b/components/utils/src/fs.rs index 39ec897..d5d907f 100644 --- a/components/utils/src/fs.rs +++ b/components/utils/src/fs.rs @@ -39,6 +39,11 @@ pub fn read_file(path: &Path) -> Result { .chain_err(|| format!("Failed to open '{:?}'", path.display()))? .read_to_string(&mut content)?; + // Remove utf-8 BOM if any. + if content.starts_with("\u{feff}") { + content.drain(..3); + } + Ok(content) } diff --git a/test_site/content/hello.md b/test_site/content/hello.md index ac36e06..4d384f3 100644 --- a/test_site/content/hello.md +++ b/test_site/content/hello.md @@ -1,2 +1,4 @@ ++++ +++ -+++ + +This file starts with a UTF-8 BOM and should be loaded