Parser
Parser class. Parses the front matter and body of a file, extracting metadata and content.
Table of Contents
Constants
- PATTERN = '^\s*(?:<!--|---|\+\+\+){1}[\n\r]+(.*?)[\n\r]+(?:-->|---|\+\+\+){1}[\n\r\s]+(.*)$'
Properties
- $body : string
- $file : SplFileInfo
- $frontmatter : string
- $file : SplFileInfo
Methods
- __construct() : mixed
- getBody() : string
- Get body.
- getFrontmatter() : string|null
- Get front matter.
- parse() : self
- Parse the contents of the file.
Constants
PATTERN
public
mixed
PATTERN
= '^\s*(?:<!--|---|\+\+\+){1}[\n\r]+(.*?)[\n\r]+(?:-->|---|\+\+\+){1}[\n\r\s]+(.*)$'
Properties
$body
protected
string
$body
$file
protected
SplFileInfo
$file
$frontmatter
protected
string
$frontmatter
Methods
__construct()
public
__construct(SplFileInfo $file) : mixed
Parameters
- $file : SplFileInfo
getBody()
Get body.
public
getBody() : string
Return values
stringgetFrontmatter()
Get front matter.
public
getFrontmatter() : string|null
Return values
string|nullparse()
Parse the contents of the file.
public
parse() : self
Example:
title: Title date: 2016-07-29
Lorem Ipsum.