Skip to content

Commit

Permalink
Merge 6095a8f into 1f78c23
Browse files Browse the repository at this point in the history
  • Loading branch information
Kron0S committed Sep 21, 2015
2 parents 1f78c23 + 6095a8f commit 3acac21
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/KzykHys/FrontMatter/FrontMatter.php
Expand Up @@ -15,19 +15,19 @@ class FrontMatter
*
* @return int
*/
public static function isValid($input)
public static function isValid($input, $format = '/^-{3}\r?\n(.*)\r?\n-{3}\r?\n/s')
{
return preg_match('/^-{3}\r?\n(.*)\r?\n-{3}\r?\n/s', $input) == 1;
return preg_match($format, $input) == 1;
}

/**
* @param $input
*
* @return Document
*/
public static function parse($input)
public static function parse($input, $format = '/^-{3}\r?\n(.*)\r?\n-{3}\r?\n/s')
{
if (!preg_match('/^-{3}\r?\n(.*)\r?\n-{3}\r?\n/s', $input, $matches)) {
if (!preg_match($format, $input, $matches)) {
return new Document($input);
}

Expand All @@ -42,10 +42,10 @@ public static function parse($input)
*
* @return string
*/
public static function dump(Document $document)
public static function dump(Document $document, $format = "---\n%s\n---\n%s")
{
return sprintf(
"---\n%s\n---\n%s",
$format,
trim(Yaml::dump($document->getConfig())),
$document->getContent()
);
Expand Down

0 comments on commit 3acac21

Please sign in to comment.