orchestra / kurenai
v0.2.0
2015-06-21 10:38 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- erusev/parsedown-extra: ~0.5
- league/commonmark: ~0.9.0
- mockery/mockery: 0.9.*
Suggests
- erusev/parsedown: Parsing markdown using erusev/parsedown (~1.5).
- erusev/parsedown-extra: Parsing markdown using erusev/parsedown-extra (~0.5).
- league/commonmark: Parsing markdown using league/commonmark (~0.9).
Conflicts
- daylerees/kurenai: ~1.0
This package is auto-updated.
Last update: 2022-02-01 12:47:54 UTC
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 分支出来的项目。