2017 © Pedro Peláez
 

library pagemark

Parse markdown for a blog or wiki

image

ryanwinchester/pagemark

Parse markdown for a blog or wiki

  • Friday, April 29, 2016
  • by ryanwinchester
  • Repository
  • 1 Watchers
  • 5 Stars
  • 181 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 3 % Grown

The README.md

Pagemark

Version Total Downloads License Scrutinizer Code Quality Build Status, (*1)

Parse markdown pages for blogs and wikis

There are multiple ways to get the content., (*2)

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:, (*3)

  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., (*4)

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);

The Versions

29/04 2016

dev-master

9999999-dev

Parse markdown for a blog or wiki

  Sources   Download

Apache-2

The Requires

 

The Development Requires

29/04 2016

v0.6.0

0.6.0.0

Parse markdown for a blog or wiki

  Sources   Download

Apache-2

The Requires

 

The Development Requires

30/09 2015

v0.5.0

0.5.0.0

Parse markdown for a blog or wiki

  Sources   Download

Apache-2

The Requires

 

The Development Requires

28/09 2015

dev-develop

dev-develop

Parse markdown for a blog or wiki

  Sources   Download

Apache-2

The Requires

 

The Development Requires