fungku/postmark
最新稳定版本:v0.6.0
Composer 安装命令:
composer require fungku/postmark
包简介
Parse markdown for a blog or wiki
README 文档
README
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:
$title- The title of the post or category taken from the file or directory name.$breadcrumbsis an array of breadcrumbs.$indexis 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
$postis 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
其他信息
- 授权协议: apache-2
- 更新时间: 2015-04-23