2017 © Pedro Peláez
 

library kurenai

Multi document parser with metadata support.

image

daylerees/kurenai

Multi document parser with metadata support.

  • Wednesday, July 18, 2018
  • by daylerees
  • Repository
  • 6 Watchers
  • 140 Stars
  • 9,814 Installations
  • PHP
  • 4 Dependents
  • 1 Suggesters
  • 11 Forks
  • 1 Open issues
  • 10 Versions
  • 1 % Grown

The README.md

Kurenai, (*1)

Kurenai

Build Status Scrutinizer Code Quality Code Coverage Code Climate HHVM Tested, (*2)

Packagist Version Packagist, (*3)

Kurenai is a document with metadata parsing library for PHP. It supports a variety of different document content and metadata parsers., (*4)


Installation

Kurenai is available on Packagist for Composer., (*5)

composer require daylerees/kurenai

Usage

Kurenai documents look like this:, (*6)

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

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

Here's an example using JSON for metadata, and Markdown for content., (*8)

{
    "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., (*9)

$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., (*10)

$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., (*11)

The document instance has a few useful methods., (*12)

$document->getRaw();

This will fetch the raw document content. Before Kurenai parsed it., (*13)

$document->getMetadata();

This will fetch the metadata, parsed into an array., (*14)

$document->getContent();

This will get the content of the document, rendered using the provided content parser., (*15)

$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']., (*16)

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

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!, (*18)

The Versions

06/04 2017

dev-test-branch

dev-test-branch

Multi document parser with metadata support.

  Sources   Download

MIT

The Requires

 

The Development Requires

markdown metadata document kurenai daylerees

07/11 2014

1.1.0

1.1.0.0

Markdown document parser with metadata.

  Sources   Download

MIT

The Requires

 

The Development Requires

markdown metadata document kurenai daylerees

27/09 2014

1.0.3

1.0.3.0

Markdown document parser with metadata.

  Sources   Download

MIT

The Requires

 

The Development Requires

markdown metadata document kurenai daylerees

22/11 2013

1.0.2

1.0.2.0

Markdown document parser with metadata.

  Sources   Download

MIT

The Requires

 

The Development Requires

markdown metadata document kurenai daylerees

10/10 2013

1.0.1

1.0.1.0

Markdown document parser with metadata.

  Sources   Download

MIT

The Requires

 

markdown metadata document kurenai daylerees

16/03 2013

dev-develop

dev-develop

Markdown document parser with metadata.

  Sources   Download

MIT

The Requires

 

markdown metadata document kurenai daylerees

16/03 2013

1.0.0

1.0.0.0

Markdown document parser with metadata.

  Sources   Download

MIT

The Requires

 

markdown metadata document kurenai daylerees