Browse Source

Do not error on files starting with utf-8 BOM

Close #501
index-subcmd
Vincent Prouillet 6 years ago
parent
commit
a0da580f87
3 changed files with 9 additions and 1 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +5
    -0
      components/utils/src/fs.rs
  3. +3
    -1
      test_site/content/hello.md

+ 1
- 0
CHANGELOG.md 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)




+ 5
- 0
components/utils/src/fs.rs 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)
} }




+ 3
- 1
test_site/content/hello.md View File

@@ -1,2 +1,4 @@
+++
+++ +++
+++

This file starts with a UTF-8 BOM and should be loaded

Loading…
Cancel
Save