Fix empty meta header

This commit is contained in:
Daniel Rudolf 2015-12-21 03:42:59 +01:00
parent 67e1e8a8ea
commit 329049bd18
2 changed files with 5 additions and 4 deletions

View file

@ -13,6 +13,7 @@ Released: -
`Pico::setConfig()` after processing has started
* [Changed] Default theme now highlights the current page and only lists pages
with a title in the navigation
* [Fixed] Support empty meta header
```
### Version 1.0.0-beta.2

View file

@ -758,11 +758,11 @@ class Pico
{
$meta = array();
$pattern = "/^(\/(\*)|---)[[:blank:]]*(?:\r)?\n"
. "(.*?)(?:\r)?\n(?(2)\*\/|---)[[:blank:]]*(?:(?:\r)?\n|$)/s";
if (preg_match($pattern, $rawContent, $rawMetaMatches)) {
. "(?:(.*?)(?:\r)?\n)?(?(2)\*\/|---)[[:blank:]]*(?:(?:\r)?\n|$)/s";
if (preg_match($pattern, $rawContent, $rawMetaMatches) && isset($rawMetaMatches[3])) {
$yamlParser = new \Symfony\Component\Yaml\Parser();
$meta = $yamlParser->parse($rawMetaMatches[3]);
$meta = array_change_key_case($meta, CASE_LOWER);
$meta = ($meta !== null) ? array_change_key_case($meta, CASE_LOWER) : array();
foreach ($headers as $fieldId => $fieldName) {
$fieldName = strtolower($fieldName);
@ -840,7 +840,7 @@ class Pico
{
// remove meta header
$metaHeaderPattern = "/^(\/(\*)|---)[[:blank:]]*(?:\r)?\n"
. "(.*?)(?:\r)?\n(?(2)\*\/|---)[[:blank:]]*(?:(?:\r)?\n|$)/s";
. "(?:(.*?)(?:\r)?\n)?(?(2)\*\/|---)[[:blank:]]*(?:(?:\r)?\n|$)/s";
$content = preg_replace($metaHeaderPattern, '', $rawContent, 1);
// replace %site_title%