From 64edc31122142fbdbc164e8e72b58cba532a76ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20Goetz?= Date: Thu, 28 Jul 2016 23:19:03 +0200 Subject: [PATCH] Support BOM at the beginning of content, fixes #372 --- docs/02_Examples/Hello_World_de.md | 2 +- libs/Tree/Content.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/02_Examples/Hello_World_de.md b/docs/02_Examples/Hello_World_de.md index 96304e2..f65a151 100644 --- a/docs/02_Examples/Hello_World_de.md +++ b/docs/02_Examples/Hello_World_de.md @@ -1,4 +1,4 @@ ---- +--- title: Hallo Welt date: 12th December 1984 --- diff --git a/libs/Tree/Content.php b/libs/Tree/Content.php index f40e303..9822750 100644 --- a/libs/Tree/Content.php +++ b/libs/Tree/Content.php @@ -103,7 +103,12 @@ class Content extends Entry $frontMatter = new FrontMatter(); - $document = $frontMatter->parse($this->getContent()); + $content = $this->getContent(); + if (substr($content, 0, 3) == "\xef\xbb\xbf") { + $content = substr($content, 3); + } + + $document = $frontMatter->parse($content); $this->attributes = array_replace_recursive($this->attributes, $document->getData()); $this->setContent($document->getContent());