• Stars
    star
    152
  • Rank 244,685 (Top 5 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 12 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kurenai is a document with metadata parsing library for PHP.

Kurenai

Kurenai

Build Status Scrutinizer Code Quality Code Coverage Code Climate HHVM Tested

Packagist Version Packagist

Kurenai is a document with metadata parsing library for PHP. It supports a variety of different document content and metadata parsers.


Installation

Kurenai is available on Packagist for Composer.

composer require daylerees/kurenai

Usage

Kurenai documents look like this:

Some form of metadata here.
===
Some form of content here.

A metadata section, and a content section seperated by three equals === signs or more.

Here's an example using JSON for metadata, and Markdown for content.

{
    "title": "Hello world!"
}
===
# Hello World

Well hello there, world!

Formats for metadata and content are interchangable using classes called parsers. First, let's create our parser instance.

$kurenai = new \Kurenai\Parser(
    new \Kurenai\Parsers\Metadata\JsonParser,
    new \Kurenai\Parsers\Content\MarkdownParser
);

In the above example, we're using a JSON metadata parser, and a Markdown content parser. We can now parse a document.

$document = $kurenai->parse('path/to/document.md');

Our documents can have any filename or extension. You can also pass the parse() function the content of a document directly.

The document instance has a few useful methods.

$document->getRaw();

This will fetch the raw document content. Before Kurenai parsed it.

$document->getMetadata();

This will fetch the metadata, parsed into an array.

$document->getContent();

This will get the content of the document, rendered using the provided content parser.

$document->get('foo.bar');

The get() method uses dot-notation to return a metadata value. For example, the above example would be equivalent to fetching $metadata['foo']['bar'].

If the subject can't be found, null will be returned. You can supply a default value as a second parameter to the method.

Metadata Parsers

Format Install Package Class
JSON N/A Kurenai\Parsers\Metdata\JsonParser
YAML symfony/yaml Kurenai\Parsers\Metdata\YamlParser
INI N/A Kurenai\Parsers\Metdata\IniParser

Content Parsers

Format Install Package Class
Plaintext (no parsing) N/A Kurenai\Parsers\Content\PlainTextParser
CommonMark league/commonmark Kurenai\Parsers\Content\CommonMarkParser
Markdown michelf/php-markdown Kurenai\Parsers\Content\MarkdownParser
Markdown Extra michelf/php-markdown Kurenai\Parsers\Content\MarkdownExtraParser
Parsedown (Github Markdown) erusev/parsedown Kurenai\Parsers\Content\ParsedownParser
Textile netcarver/textile Kurenai\Parsers\Content\TextileParser

Enjoy using Kurenai!

More Repositories

1

colour-schemes

Colour schemes for a variety of editors created by Dayle Rees.
HTML
9,319
star
2

scientist

A PHP experimentation library inspired by Github's own Scientist.
PHP
781
star
3

material-peacock

Peacock colour scheme optimized for the Material UI PHPStorm theme.
573
star
4

test-driven-development-example

An introduction to Test-Driven Development (TDD).
PHP
510
star
5

dependency-injection-example

An introduction to Dependency Injection.
PHP
419
star
6

laravel-website-configs

Webserver configuration files for Laravel 4.
336
star
7

anbu

Anbu profiler for the Laravel PHP Framework.
CSS
308
star
8

sanitizer

Sanitize data using a number of mutation methods.
PHP
261
star
9

laravel-resources

A list of resources for the Laravel framework.
65
star
10

laravel-vagrant

Vagrant configuration for Laravel 4.
Ruby
59
star
11

container-debug

Container debug command for Laravel four.
PHP
57
star
12

scientist-laravel

Allow the Scientist library to be used with the Laravel PHP framework.
PHP
54
star
13

default-github-templates

Default templates for contribution guide, issues, and pull requests.
41
star
14

blog-tutorial-code

The code that accompanies the blog tutorial chapter.
PHP
19
star
15

inversion-of-control-container-example

PHP
15
star
16

presenters

PHP
9
star
17

daylerees.github.io

CSS
7
star
18

container-example

Example code to accompany article @ https://daylerees.com/container-baking
PHP
5
star
19

rainglow-atom

300+ themes for Atom editor.
CSS
4
star
20

resume

Resume/CV for Dayle Rees.
HTML
4
star
21

anbu-agent

Agent for the Anbu profiler.
PHP
3
star
22

events-challenge

Go
2
star
23

brackets

320+ color themes for Adobe Brackets.
CSS
2
star
24

rainbow

Color scheme generation.
JavaScript
1
star
25

go-exercises

Just some Golang exercises
Go
1
star
26

json-rpc-foundation

Implementation of JSON-RPC protocol using Symfony HTTP Foundation.
PHP
1
star