Skip to content

Markdown with meta frontmatters of type json, toml and yaml

License

Notifications You must be signed in to change notification settings

hyn/frontmatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frontmatter

GitHub license Latest Stable Version Build Status Total Downloads Donate

An easy package to parse any markdown file that includes some kind of meta data (commonly known as frontmatter).

Installation

composer require hyn/frontmatter

Usage

The easiest way is using inversion of control, but feel free to instantiate the class the way you see fit:

$parser = new \Hyn\Frontmatter\Parser(new \cebe\markdown\Markdown);

// Uses json per default, but set specifically:
$parser->setFrontmatter(\Hyn\Frontmatter\Frontmatters\JsonFrontmatter::class);
// Use toml:
$parser->setFrontmatter(\Hyn\Frontmatter\Frontmatters\TomlFrontmatter::class);
// Or use yaml:
$parser->setFrontmatter(\Hyn\Frontmatter\Frontmatters\YamlFrontmatter::class);

// And parse the markdown file:
$contents = $parser->parse(file_get_contents('the-file.md'));
// Get meta
$meta = $parser->getMeta();

About

Markdown with meta frontmatters of type json, toml and yaml

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages