Do not error on files starting with utf-8 BOM

Close #501
This commit is contained in:
Vincent Prouillet 2018-10-29 12:43:51 +01:00
parent 8a6d3d42ec
commit a0da580f87
3 changed files with 9 additions and 1 deletions

View file

@ -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 - Ensure content directory exists before rendering aliases
- Do not include drafts in pagination - 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 - 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) ## 0.4.2 (2018-09-03)

View file

@ -39,6 +39,11 @@ pub fn read_file(path: &Path) -> Result<String> {
.chain_err(|| format!("Failed to open '{:?}'", path.display()))? .chain_err(|| format!("Failed to open '{:?}'", path.display()))?
.read_to_string(&mut content)?; .read_to_string(&mut content)?;
// Remove utf-8 BOM if any.
if content.starts_with("\u{feff}") {
content.drain(..3);
}
Ok(content) Ok(content)
} }

View file

@ -1,2 +1,4 @@
+++
+++ +++
+++
This file starts with a UTF-8 BOM and should be loaded