Fix empty meta header
This commit is contained in:
parent
67e1e8a8ea
commit
329049bd18
|
@ -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
|
||||
|
|
|
@ -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%
|
||||
|
|
Loading…
Reference in a new issue