mnapoli/front-yaml 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mnapoli/front-yaml

最新稳定版本:2.0.5

Composer 安装命令:

composer require mnapoli/front-yaml

包简介

README 文档

README

An implementation of YAML Front matter for PHP. It can parse both YAML and Markdown.

Total Downloads

Installation

Require the project with Composer:

composer require mnapoli/front-yaml

Usage

$parser = new Mni\FrontYAML\Parser;

$document = $parser->parse($str);

$yaml = $document->getYAML();
$html = $document->getContent();

If you don't want the Markdown to be parsed (maybe because it is not Markdown):

$document = $parser->parse($str, false);

Example

The following file:

---
foo: bar
---
This is **strong**.

Will give:

var_export($document->getYAML());
// array("foo" => "bar")

var_export($document->getContent());
// "<p>This is <strong>strong</strong></p>"

YAML and Markdown parsers

$parser = new Mni\FrontYAML\Parser($yamlParser, $markdownParser);

This library uses dependency injection and abstraction to allow you to provide your own YAML or Markdown parser.

interface YAMLParser
{
    public function parse($yaml);
}

FrontYAML uses by default Symfony's YAML parser.

interface MarkdownParser
{
    public function parse($markdown);
}

FrontYAML uses by default the League CommonMark parser.

统计信息

  • 总下载量: 5.48M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 288
  • 点击次数: 1
  • 依赖项目数: 56
  • 推荐数: 0

GitHub 信息

  • Stars: 285
  • Watchers: 4
  • Forks: 29
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-01-24