laravie / kurenai
具有元数据的Markdown文档解析器。
v2.0.0
2018-05-06 14:58 UTC
Requires
- php: >=7.1
- symfony/yaml: ^3.0 || ^4.0
Requires (Dev)
- erusev/parsedown: ^1.7.1
- erusev/parsedown-extra: ~0.7
- league/commonmark: ~0.17
- mockery/mockery: ^1.0
- phpunit/phpunit: ^7.0
Suggests
- erusev/parsedown: Parsing markdown using erusev/parsedown (^1.7.1).
- erusev/parsedown-extra: Parsing markdown using erusev/parsedown-extra (~0.7).
- league/commonmark: Parsing markdown using league/commonmark (~0.17).
Conflicts
- daylerees/kurenai: ~1.0
README
Kurenai是一个Markdown文档解析器,它允许将额外的元数据关联到文档中。
简介
困惑?让我们看看它是如何工作的。
这是您的文档可能的样子
title: This is my document title.
slug: this-is-the-slug
date: 12th December 1984
-------
This is my **markdown** content!
这里是如何使用Kurenai进行解析的
<?php // Use the Kurenai document parser. use Kurenai\Document; use Kurenai\DocumentParser; use Kurenai\Parser\Parsedown; // Load our document source. $source = file_get_contents('my_document.md'); // Create a new document parser $parser = new DocumentParser(new Document(new Parsedown)); // Parse the loaded source. $document = $parser->parse($source); // To get the document content in raw markdown format.. // This is my **markdown** content! $rawMarkdown = $document->getContent(); // To get the converted HTML content.. // <p>This is my <strong>markdown</strong> content!</p> $html = $document->getHtmlContent(); // To access the full array of metadata // array( // 'title' => 'This is my document title.', // 'slug' => 'this-is-the-slug', // 'date' => '12th December 1984' // ); $metadata = $document->get(); // To access a piece of metadata by key (default: null).. // this-is-the-slug $slug = $document->get('slug');
起源
Kurenai是从daylerees/kurenai分支出来的项目。