fungku/postmark 问题修复 & 功能扩展

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

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

fungku/postmark

最新稳定版本:v0.6.0

Composer 安装命令:

composer require fungku/postmark

包简介

Parse markdown for a blog or wiki

README 文档

README

Version Total Downloads License Scrutinizer Code Quality Build Status

Parse markdown pages for blogs and wikis

There are multiple ways to get the content.

use Pagemark\Pagemark;

$basePath = '/my/path/to/wiki';
$post = 'Category/Subcategory/My-Post';

$content = Pagemark::parse($basePath, $post);
use Pagemark\Pagemark;

$pagemark = Pagemark::create();

$basePath = '/my/path/to/wiki';
$post = 'Category/Subcategory/My-Post';

$content = $pagemark->getContent($basePath, $post);
use Pagemark\Pagemark;
use Pagemark\Parser;
use Illuminate\Filesystem\Filesystem;
use Parsedown;

$pagemark = new Pagemark(new Filesystem, new Parser(new Parsedown));

$basePath = '/my/path/to/wiki';
$post = 'Category/Subcategory/My-Post';

$content = $pagemark->getContent($basePath, $post);

Example return value

$content = [
    'title' => 'File',
    'breadcrumbs' => [
        [
            'href' => '/Category',
            'name' => 'Category'
        ],
        [
            'href' => '/Category/Subcategory',
            'name' => 'Subcategory'
        ],
        [
            'href' => '/Category/Subcategory/My-Post',
            'name' => 'My Post'
        ],
    ],
    'index'       => ['subcategories' => [], 'files' => []],
    'post'        => '<p>Some text from My-Post.md</p>'
];

Explanation:

  1. $title - The title of the post or category taken from the file or directory name.
  2. $breadcrumbs is an array of breadcrumbs.
  3. $index is available if you have navigated to a directory, or an empty array otherwise
    • $index['subcategories'] is an array of subdirectories in your current directory
    • $index['files'] is an array of files in your current directory
  4. $post is a string of your parsed markdown content

Using a different parser.

By default the markdown parser used is erusev/parsedown. To use a different one, you need to make your own parser that implements the Parseable interface or create an adapter for a different library that implements Parseable.

use Pagemark\Pagemark;

$myCustomParser = new CustomParser;

$pagemark = Pagemark::create($myCustomParser);

$basePath = '/my/path/to/wiki';
$post = 'Category/Subcategory/My-Post';

$content = $pagemark->getContent($basePath, $post);
use Pagemark\Pagemark;
use Pagemark\Parser;
use Illuminate\Filesystem\Filesystem;

$myCustomParser = new CustomParser;

$pagemark = new Pagemark(new Filesystem, $myCustomParser);

$basePath = '/my/path/to/wiki';
$post = 'Category/Subcategory/My-Post';

$content = $pagemark->getContent($basePath, $post);

统计信息

  • 总下载量: 203
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: apache-2
  • 更新时间: 2015-04-23