hyn / frontmatter
Markdown including meta information parsing from frontmatters
Installs: 36 436
Dependents: 3
Suggesters: 0
Security: 0
Stars: 11
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- cebe/markdown: ^1.1
- symfony/yaml: ^3.2
- yosymfony/toml: ^0.3.3
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2024-11-05 18:59:40 UTC
README
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();