Cecil

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

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

$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
string

getFrontmatter()

Get front matter.

public getFrontmatter() : string|null
Return values
string|null

parse()

Parse the contents of the file.

public parse() : self

Example:

title: Title date: 2016-07-29

Lorem Ipsum.

Tags
throws
RuntimeException
Return values
self
 
On this page

Search results