v0.7
* [New] Added before_read_file_meta and get_page_data plugin hooks to customize page meta data * [Changed] Make get_files() ignore dotfiles * [Changed] Make get_pages() ignore Emacs and temp files * [Changed] Use composer version of Markdown * [Changed] Other small tweaks * [Fixed] Date warnings and other small bugs
This commit is contained in:
parent
69d67b2b71
commit
45cd4ca5b7
19 changed files with 3637 additions and 45 deletions
20
.gitignore
vendored
20
.gitignore
vendored
|
@ -1,5 +1,23 @@
|
|||
# Composer
|
||||
composer.lock
|
||||
composer.phar
|
||||
|
||||
# Twig
|
||||
vendor/twig/twig/doc/*
|
||||
vendor/twig/twig/ext/*
|
||||
vendor/twig/twig/test/*
|
||||
vendor/twig/twig/test/*
|
||||
|
||||
# OS Generated
|
||||
.DS_Store*
|
||||
ehthumbs.db
|
||||
Icon?
|
||||
Thumbs.db
|
||||
*.swp
|
||||
|
||||
# User themes
|
||||
themes/*
|
||||
!themes/index.html
|
||||
!themes/default/*
|
||||
|
||||
# User config
|
||||
config.php
|
|
@ -1,5 +1,13 @@
|
|||
*** Pico Changelog ***
|
||||
|
||||
2013.09.04 - version 0.7
|
||||
* [New] Added before_read_file_meta and get_page_data plugin hooks to customize page meta data
|
||||
* [Changed] Make get_files() ignore dotfiles
|
||||
* [Changed] Make get_pages() ignore Emacs and temp files
|
||||
* [Changed] Use composer version of Markdown
|
||||
* [Changed] Other small tweaks
|
||||
* [Fixed] Date warnings and other small bugs
|
||||
|
||||
2013.05.07 - version 0.6.2
|
||||
* [Changed] Replaced glob_recursive with get_files
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"require": {
|
||||
"twig/twig": "1.12.*",
|
||||
"michelf/php-markdown": "1.3"
|
||||
"michelf/php-markdown": "1.3"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,4 @@ $config['excerpt_length'] = 50; // The pages excerpt length (in words)
|
|||
|
||||
$config['custom_setting'] = 'Hello'; // Can be accessed by {{ config.custom_setting }} in a theme
|
||||
|
||||
*/
|
||||
|
||||
?>
|
||||
*/
|
|
@ -94,7 +94,15 @@ Pages can be used like:
|
|||
{% endfor %}
|
||||
</ul></pre>
|
||||
|
||||
### Plugins
|
||||
|
||||
See [http://pico.dev7studios.com/plugins](http://pico.dev7studios.com/plugins)
|
||||
|
||||
### Config
|
||||
|
||||
You can override the default Pico settings (and add your own custom settings) by editing config.php in the root Pico directory. The config.php file
|
||||
lists all of the settings and their defaults. To override a setting, simply uncomment it in config.php and set your custom value.
|
||||
|
||||
### Documentation
|
||||
|
||||
For more help have a look at the Pico documentation at [http://pico.dev7studios.com/docs](http://pico.dev7studios.com/docs)
|
||||
|
|
23
lib/pico.php
23
lib/pico.php
|
@ -1,12 +1,13 @@
|
|||
<?php
|
||||
use \Michelf\MarkdownExtra;
|
||||
|
||||
/**
|
||||
* Pico
|
||||
*
|
||||
* @author Gilbert Pellegrom
|
||||
* @link http://pico.dev7studios.com
|
||||
* @license http://opensource.org/licenses/MIT
|
||||
* @version 0.6.2
|
||||
* @version 0.7
|
||||
*/
|
||||
class Pico {
|
||||
|
||||
|
@ -66,7 +67,7 @@ class Pico {
|
|||
$current_page = array();
|
||||
$next_page = array();
|
||||
while($current_page = current($pages)){
|
||||
if($meta['title'] == $current_page['title']){
|
||||
if((isset($meta['title'])) && ($meta['title'] == $current_page['title'])){
|
||||
break;
|
||||
}
|
||||
next($pages);
|
||||
|
@ -166,7 +167,7 @@ class Pico {
|
|||
}
|
||||
}
|
||||
|
||||
if($headers['date']) $headers['date_formatted'] = date($config['date_format'], strtotime($headers['date']));
|
||||
if(isset($headers['date'])) $headers['date_formatted'] = date($config['date_format'], strtotime($headers['date']));
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
@ -178,10 +179,8 @@ class Pico {
|
|||
*/
|
||||
private function get_config()
|
||||
{
|
||||
if(!file_exists(ROOT_DIR .'config.php')) return array();
|
||||
|
||||
global $config;
|
||||
require_once(ROOT_DIR .'config.php');
|
||||
@include_once(ROOT_DIR .'config.php');
|
||||
|
||||
$defaults = array(
|
||||
'site_title' => 'Pico',
|
||||
|
@ -235,11 +234,11 @@ class Pico {
|
|||
$url = str_replace('index'. CONTENT_EXT, '', $url);
|
||||
$url = str_replace(CONTENT_EXT, '', $url);
|
||||
$data = array(
|
||||
'title' => $page_meta['title'],
|
||||
'title' => isset($page_meta['title']) ? $page_meta['title'] : '',
|
||||
'url' => $url,
|
||||
'author' => $page_meta['author'],
|
||||
'date' => $page_meta['date'],
|
||||
'date_formatted' => date($config['date_format'], strtotime($page_meta['date'])),
|
||||
'author' => isset($page_meta['author']) ? $page_meta['author'] : '',
|
||||
'date' => isset($page_meta['date']) ? $page_meta['date'] : '',
|
||||
'date_formatted' => isset($page_meta['date']) ? date($config['date_format'], strtotime($page_meta['date'])) : '',
|
||||
'content' => $page_content,
|
||||
'excerpt' => $this->limit_words(strip_tags($page_content), $excerpt_length)
|
||||
);
|
||||
|
@ -247,7 +246,7 @@ class Pico {
|
|||
// Extend the data provided with each page by hooking into the data array
|
||||
$this->run_hooks('get_page_data', array(&$data, $page_meta));
|
||||
|
||||
if($order_by == 'date'){
|
||||
if($order_by == 'date' && isset($page_meta['date'])){
|
||||
$sorted_pages[$page_meta['date'].$date_id] = $data;
|
||||
$date_id++;
|
||||
}
|
||||
|
@ -347,5 +346,3 @@ class Pico {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -44,6 +44,11 @@ class Pico_Plugin {
|
|||
|
||||
}
|
||||
|
||||
public function before_read_file_meta(&$headers)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function file_meta(&$meta)
|
||||
{
|
||||
|
||||
|
@ -54,6 +59,11 @@ class Pico_Plugin {
|
|||
|
||||
}
|
||||
|
||||
public function get_page_data(&$data, $page_meta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function get_pages(&$pages, &$current_page, &$prev_page, &$next_page)
|
||||
{
|
||||
|
||||
|
|
4
vendor/autoload.php
vendored
4
vendor/autoload.php
vendored
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
// autoload.php generated by Composer
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit5115ee54a7a3f173d564b433db6d791a::getLoader();
|
||||
return ComposerAutoloaderInit68d29614b81b64051229769b084d96b6::getLoader();
|
||||
|
|
40
vendor/composer/ClassLoader.php
vendored
40
vendor/composer/ClassLoader.php
vendored
|
@ -49,7 +49,7 @@ class ClassLoader
|
|||
|
||||
public function getPrefixes()
|
||||
{
|
||||
return $this->prefixes;
|
||||
return call_user_func_array('array_merge', $this->prefixes);
|
||||
}
|
||||
|
||||
public function getFallbackDirs()
|
||||
|
@ -98,19 +98,21 @@ class ClassLoader
|
|||
|
||||
return;
|
||||
}
|
||||
if (!isset($this->prefixes[$prefix])) {
|
||||
$this->prefixes[$prefix] = (array) $paths;
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixes[$first][$prefix])) {
|
||||
$this->prefixes[$first][$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixes[$prefix] = array_merge(
|
||||
$this->prefixes[$first][$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixes[$prefix]
|
||||
$this->prefixes[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixes[$prefix] = array_merge(
|
||||
$this->prefixes[$prefix],
|
||||
$this->prefixes[$first][$prefix] = array_merge(
|
||||
$this->prefixes[$first][$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
@ -119,8 +121,8 @@ class ClassLoader
|
|||
/**
|
||||
* Registers a set of classes, replacing any others previously set.
|
||||
*
|
||||
* @param string $prefix The classes prefix
|
||||
* @param array|string $paths The location(s) of the classes
|
||||
* @param string $prefix The classes prefix
|
||||
* @param array|string $paths The location(s) of the classes
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
|
@ -129,7 +131,7 @@ class ClassLoader
|
|||
|
||||
return;
|
||||
}
|
||||
$this->prefixes[$prefix] = (array) $paths;
|
||||
$this->prefixes[substr($prefix, 0, 1)][$prefix] = (array) $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,6 +197,7 @@ class ClassLoader
|
|||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
|
||||
if ('\\' == $class[0]) {
|
||||
$class = substr($class, 1);
|
||||
}
|
||||
|
@ -205,7 +208,7 @@ class ClassLoader
|
|||
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)) . DIRECTORY_SEPARATOR;
|
||||
$classPath = strtr(substr($class, 0, $pos), '\\', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
$className = substr($class, $pos + 1);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
|
@ -213,13 +216,16 @@ class ClassLoader
|
|||
$className = $class;
|
||||
}
|
||||
|
||||
$classPath .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
|
||||
$classPath .= strtr($className, '_', DIRECTORY_SEPARATOR) . '.php';
|
||||
|
||||
foreach ($this->prefixes as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
|
||||
return $dir . DIRECTORY_SEPARATOR . $classPath;
|
||||
$first = $class[0];
|
||||
if (isset($this->prefixes[$first])) {
|
||||
foreach ($this->prefixes[$first] as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
|
||||
return $dir . DIRECTORY_SEPARATOR . $classPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
vendor/composer/autoload_classmap.php
vendored
2
vendor/composer/autoload_classmap.php
vendored
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
// autoload_classmap.php generated by Composer
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
|
5
vendor/composer/autoload_namespaces.php
vendored
5
vendor/composer/autoload_namespaces.php
vendored
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
// autoload_namespaces.php generated by Composer
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Twig_' => $vendorDir . '/twig/twig/lib',
|
||||
'Twig_' => array($vendorDir . '/twig/twig/lib'),
|
||||
'Michelf' => array($vendorDir . '/michelf/php-markdown'),
|
||||
);
|
||||
|
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
// autoload_real.php generated by Composer
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit5115ee54a7a3f173d564b433db6d791a
|
||||
class ComposerAutoloaderInit68d29614b81b64051229769b084d96b6
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -19,16 +19,16 @@ class ComposerAutoloaderInit5115ee54a7a3f173d564b433db6d791a
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit5115ee54a7a3f173d564b433db6d791a', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit68d29614b81b64051229769b084d96b6', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit5115ee54a7a3f173d564b433db6d791a', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit68d29614b81b64051229769b084d96b6', 'loadClassLoader'));
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->add($namespace, $path);
|
||||
$loader->set($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
|
|
53
vendor/composer/installed.json
vendored
53
vendor/composer/installed.json
vendored
|
@ -49,5 +49,58 @@
|
|||
"keywords": [
|
||||
"templating"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "michelf/php-markdown",
|
||||
"version": "1.3",
|
||||
"version_normalized": "1.3.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/michelf/php-markdown.git",
|
||||
"reference": "fcdd3e0781ae40c2b9847874e0755ff4f5559688"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/fcdd3e0781ae40c2b9847874e0755ff4f5559688",
|
||||
"reference": "fcdd3e0781ae40c2b9847874e0755ff4f5559688",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"time": "2013-04-11 18:53:11",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-lib": "1.3.x-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Michelf": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michel Fortin",
|
||||
"email": "michel.fortin@michelf.ca",
|
||||
"homepage": "http://michelf.ca/",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "John Gruber",
|
||||
"homepage": "http://daringfireball.net/"
|
||||
}
|
||||
],
|
||||
"description": "PHP Markdown",
|
||||
"homepage": "http://michelf.ca/projects/php-markdown/",
|
||||
"keywords": [
|
||||
"markdown"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
36
vendor/michelf/php-markdown/License.md
vendored
Normal file
36
vendor/michelf/php-markdown/License.md
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
PHP Markdown Lib
|
||||
Copyright (c) 2004-2013 Michel Fortin
|
||||
<http://michelf.ca/>
|
||||
All rights reserved.
|
||||
|
||||
Based on Markdown
|
||||
Copyright (c) 2003-2006 John Gruber
|
||||
<http://daringfireball.net/>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name "Markdown" nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
This software is provided by the copyright holders and contributors "as
|
||||
is" and any express or implied warranties, including, but not limited
|
||||
to, the implied warranties of merchantability and fitness for a
|
||||
particular purpose are disclaimed. In no event shall the copyright owner
|
||||
or contributors be liable for any direct, indirect, incidental, special,
|
||||
exemplary, or consequential damages (including, but not limited to,
|
||||
procurement of substitute goods or services; loss of use, data, or
|
||||
profits; or business interruption) however caused and on any theory of
|
||||
liability, whether in contract, strict liability, or tort (including
|
||||
negligence or otherwise) arising in any way out of the use of this
|
||||
software, even if advised of the possibility of such damage.
|
3096
vendor/michelf/php-markdown/Michelf/Markdown.php
vendored
Normal file
3096
vendor/michelf/php-markdown/Michelf/Markdown.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
40
vendor/michelf/php-markdown/Michelf/MarkdownExtra.php
vendored
Normal file
40
vendor/michelf/php-markdown/Michelf/MarkdownExtra.php
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
#
|
||||
# Markdown Extra - A text-to-HTML conversion tool for web writers
|
||||
#
|
||||
# PHP Markdown Extra
|
||||
# Copyright (c) 2004-2013 Michel Fortin
|
||||
# <http://michelf.com/projects/php-markdown/>
|
||||
#
|
||||
# Original Markdown
|
||||
# Copyright (c) 2004-2006 John Gruber
|
||||
# <http://daringfireball.net/projects/markdown/>
|
||||
#
|
||||
namespace Michelf;
|
||||
|
||||
|
||||
# Just force Michelf/Markdown.php to load. This is needed to load
|
||||
# the temporary implementation class. See below for details.
|
||||
\Michelf\Markdown::MARKDOWNLIB_VERSION;
|
||||
|
||||
#
|
||||
# Markdown Extra Parser Class
|
||||
#
|
||||
# Note: Currently the implementation resides in the temporary class
|
||||
# \Michelf\MarkdownExtra_TmpImpl (in the same file as \Michelf\Markdown).
|
||||
# This makes it easier to propagate the changes between the three different
|
||||
# packaging styles of PHP Markdown. Once this issue is resolved, the
|
||||
# _MarkdownExtra_TmpImpl will disappear and this one will contain the code.
|
||||
#
|
||||
|
||||
class MarkdownExtra extends \Michelf\_MarkdownExtra_TmpImpl {
|
||||
|
||||
### Parser Implementation ###
|
||||
|
||||
# Temporarily, the implemenation is in the _MarkdownExtra_TmpImpl class.
|
||||
# See note above.
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
259
vendor/michelf/php-markdown/Readme.md
vendored
Normal file
259
vendor/michelf/php-markdown/Readme.md
vendored
Normal file
|
@ -0,0 +1,259 @@
|
|||
PHP Markdown
|
||||
============
|
||||
|
||||
PHP Markdown Lib 1.3 - 11 Apr 2013
|
||||
|
||||
by Michel Fortin
|
||||
<http://michelf.ca/>
|
||||
|
||||
based on Markdown by John Gruber
|
||||
<http://daringfireball.net/>
|
||||
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
This is a library package that includes the PHP Markdown parser and its
|
||||
sibling PHP Markdown Extra which additional features.
|
||||
|
||||
Markdown is a text-to-HTML conversion tool for web writers. Markdown
|
||||
allows you to write using an easy-to-read, easy-to-write plain text
|
||||
format, then convert it to structurally valid XHTML (or HTML).
|
||||
|
||||
"Markdown" is two things: a plain text markup syntax, and a software
|
||||
tool, written in Perl, that converts the plain text markup to HTML.
|
||||
PHP Markdown is a port to PHP of the original Markdown program by
|
||||
John Gruber.
|
||||
|
||||
PHP Markdown can work as a plug-in for WordPress, as a modifier for
|
||||
the Smarty templating engine, or as a replacement for Textile
|
||||
formatting in any software that supports Textile.
|
||||
|
||||
Full documentation of Markdown's syntax is available on John's
|
||||
Markdown page: <http://daringfireball.net/projects/markdown/>
|
||||
|
||||
|
||||
Requirement
|
||||
-----------
|
||||
|
||||
This library package requires PHP 5.3 or later.
|
||||
|
||||
Note: The older plugin/library hybrid package for PHP Markdown and
|
||||
PHP Markdown Extra is still maintained and will work with PHP 4.0.5 and later.
|
||||
|
||||
Before PHP 5.3.7, pcre.backtrack_limit defaults to 100 000, which is too small
|
||||
in many situations. You might need to set it to higher values. Later PHP
|
||||
releases defaults to 1 000 000, which is usually fine.
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
This library package is meant to be used with class autoloading. For autoloading
|
||||
to work, your project needs have setup a PSR-0-compatible autoloader. See the
|
||||
included Readme.php file for a minimal autoloader setup. (If you don't want to
|
||||
use autoloading you can do a classic `require_once` to manually include the
|
||||
files prior use instead.)
|
||||
|
||||
With class autoloading in place, putting the 'Michelf' folder in your
|
||||
include path should be enough for this to work:
|
||||
|
||||
use \Michelf\Markdown;
|
||||
$my_html = Markdown::defaultTransform($my_text);
|
||||
|
||||
Markdown Extra syntax is also available the same way:
|
||||
|
||||
use \Michelf\MarkdownExtra;
|
||||
$my_html = MarkdownExtra::defaultTransform($my_text);
|
||||
|
||||
If you wish to use PHP Markdown with another text filter function
|
||||
built to parse HTML, you should filter the text *after* the `transform`
|
||||
function call. This is an example with [PHP SmartyPants][psp]:
|
||||
|
||||
use \Michelf\Markdown, \Michelf\SmartyPants;
|
||||
$my_html = Markdown::defaultTransform($my_text);
|
||||
$my_html = SmartyPants::defaultTransform($my_html);
|
||||
|
||||
All these examples are using the static `defaultTransform` static function
|
||||
found inside the parser class. If you want to customize the parser
|
||||
configuration, you can also instantiate it directly and change some
|
||||
configuration variables:
|
||||
|
||||
use \Michelf\MarkdownExtra;
|
||||
$parser = new MarkdownExtra;
|
||||
$parser->fn_id_prefix = "post22-";
|
||||
$my_html = $parser->transform($my_text);
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
This library package is meant to be used with class autoloading. For autoloading
|
||||
to work, your project needs have setup a PSR-0-compatible autoloader. See the
|
||||
included Readme.php file for a minimal autoloader setup. (If you don't want to
|
||||
use autoloading you can do a classic `require_once` to manually include the
|
||||
files prior use instead.)
|
||||
|
||||
With class autoloading in place, putting the 'Michelf' folder in your
|
||||
include path should be enough for this to work:
|
||||
|
||||
use \Michelf\Markdown;
|
||||
$my_html = Markdown::defaultTransform($my_text);
|
||||
|
||||
Markdown Extra syntax is also available the same way:
|
||||
|
||||
use \Michelf\MarkdownExtra;
|
||||
$my_html = MarkdownExtra::defaultTransform($my_text);
|
||||
|
||||
If you wish to use PHP Markdown with another text filter function
|
||||
built to parse HTML, you should filter the text *after* the `transform`
|
||||
function call. This is an example with [PHP SmartyPants][psp]:
|
||||
|
||||
use \Michelf\Markdown, \Michelf\SmartyPants;
|
||||
$my_html = Markdown::defaultTransform($my_text);
|
||||
$my_html = SmartyPants::defaultTransform($my_html);
|
||||
|
||||
All these examples are using the static `defaultTransform` static function
|
||||
found inside the parser class. If you want to customize the parser
|
||||
configuration, you can also instantiate it directly and change some
|
||||
configuration variables:
|
||||
|
||||
use \Michelf\MarkdownExtra;
|
||||
$parser = new MarkdownExtra;
|
||||
$parser->fn_id_prefix = "post22-";
|
||||
$my_html = $parser->transform($my_text);
|
||||
|
||||
To learn more, see the full list of [configuration variables].
|
||||
|
||||
[configuration variables]: http://michelf.ca/project/php-markdown/configuration/
|
||||
|
||||
|
||||
Public API and Versionning Policy
|
||||
---------------------------------
|
||||
|
||||
Version numbers are of the form *major*.*minor*.*patch*.
|
||||
|
||||
The public API of PHP Markdown consist of the two parser classes `Markdown`
|
||||
and `MarkdownExtra`, their constructors, the `transform` and `defaultTransform`
|
||||
functions and their configuration variables. The public API is stable for
|
||||
a given major version number. It might get additions when the minor version
|
||||
number increments.
|
||||
|
||||
**Protected members are not considered public API.** This is unconventionnal
|
||||
and deserves an explanation. Incrementing the major version number every time
|
||||
the underlying implementation of something changes is going to give nonsential
|
||||
version numbers for the vast majority of people who just use the parser.
|
||||
Protected members are meant to create parser subclasses that behave in
|
||||
different ways. Very few people create parser subclasses. I don't want to
|
||||
discourage it by making everything private, but at the same time I can't
|
||||
guarenty any stable hook between versions if you use protected members.
|
||||
|
||||
**Syntax changes** will increment the minor number for new features, and the
|
||||
patch number for small corrections. A *new feature* is something that needs a
|
||||
change in the syntax documentation. Note that since PHP Markdown Lib includes
|
||||
two parsers, a syntax change for either of them will increment the minor
|
||||
number. Also note that there is nothigng perfectly backward-compatible with the
|
||||
Markdown syntax: all inputs are always valid, so new features always replace
|
||||
something that was previously legal, although generally non-sensial to do.
|
||||
|
||||
|
||||
Bugs
|
||||
----
|
||||
|
||||
To file bug reports please send email to:
|
||||
<michel.fortin@michelf.ca>
|
||||
|
||||
Please include with your report: (1) the example input; (2) the output you
|
||||
expected; (3) the output PHP Markdown actually produced.
|
||||
|
||||
If you have a problem where Markdown gives you an empty result, first check
|
||||
that the backtrack limit is not too low by running `php --info | grep pcre`.
|
||||
See Installation and Requirement above for details.
|
||||
|
||||
|
||||
Version History
|
||||
---------------
|
||||
|
||||
PHP Markdown Lib 1.3 (11 Apr 2013):
|
||||
|
||||
This is the first release of PHP Markdown Lib. This package requires PHP
|
||||
version 4.3 or later and is designed to work with PSR-0 autoloading and,
|
||||
optionally with Composer. Here is a list of the changes since
|
||||
PHP Markdown Extra 1.2.6:
|
||||
|
||||
* Plugin interface for Wordpress and other systems is no longer present in
|
||||
the Lib package. The classic package is still available if you need it:
|
||||
<http://michelf.ca/projects/php-markdown/classic/>
|
||||
|
||||
* Added `public` and `protected` protection attributes, plus a section about
|
||||
what is "public API" and what isn't in the Readme file.
|
||||
|
||||
* Changed HTML output for footnotes: now instead of adding `rel` and `rev`
|
||||
attributes, footnotes links have the class name `footnote-ref` and
|
||||
backlinks `footnote-backref`.
|
||||
|
||||
* Fixed some regular expressions to make PCRE not shout warnings about POSIX
|
||||
collation classes (dependent on your version of PCRE).
|
||||
|
||||
* Added optional class and id attributes to images and links using the same
|
||||
syntax as for headers:
|
||||
|
||||
[link](url){#id .class}
|
||||
![img](url){#id .class}
|
||||
|
||||
It work too for reference-style links and images. In this case you need
|
||||
to put those attributes at the reference definition:
|
||||
|
||||
[link][linkref] or [linkref]
|
||||
![img][linkref]
|
||||
|
||||
[linkref]: url "optional title" {#id .class}
|
||||
|
||||
* Fixed a PHP notice message triggered when some table column separator
|
||||
markers are missing on the separator line below column headers.
|
||||
|
||||
* Fixed a small mistake that could cause the parser to retain an invalid
|
||||
state related to parsing links across multiple runs. This was never
|
||||
observed (that I know of), but it's still worth fixing.
|
||||
|
||||
|
||||
Copyright and License
|
||||
---------------------
|
||||
|
||||
PHP Markdown Lib
|
||||
Copyright (c) 2004-2013 Michel Fortin
|
||||
<http://michelf.ca/>
|
||||
All rights reserved.
|
||||
|
||||
Based on Markdown
|
||||
Copyright (c) 2003-2005 John Gruber
|
||||
<http://daringfireball.net/>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name "Markdown" nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
This software is provided by the copyright holders and contributors "as
|
||||
is" and any express or implied warranties, including, but not limited
|
||||
to, the implied warranties of merchantability and fitness for a
|
||||
particular purpose are disclaimed. In no event shall the copyright owner
|
||||
or contributors be liable for any direct, indirect, incidental, special,
|
||||
exemplary, or consequential damages (including, but not limited to,
|
||||
procurement of substitute goods or services; loss of use, data, or
|
||||
profits; or business interruption) however caused and on any theory of
|
||||
liability, whether in contract, strict liability, or tort (including
|
||||
negligence or otherwise) arising in any way out of the use of this
|
||||
software, even if advised of the possibility of such damage.
|
31
vendor/michelf/php-markdown/Readme.php
vendored
Normal file
31
vendor/michelf/php-markdown/Readme.php
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
# This file passes the content of the Readme.md file in the same directory
|
||||
# through the Markdown filter. You can adapt this sample code in any way
|
||||
# you like.
|
||||
|
||||
# Install PSR-0-compatible class autoloader
|
||||
spl_autoload_register(function($class){
|
||||
require preg_replace('{\\\\|_(?!.*\\\\)}', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php';
|
||||
});
|
||||
|
||||
# Get Markdown class
|
||||
use \Michelf\Markdown;
|
||||
|
||||
# Read file and pass content through the Markdown praser
|
||||
$text = file_get_contents('Readme.md');
|
||||
$html = Markdown::defaultTransform($text);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>PHP Markdown Lib - Readme</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
# Put HTML content in the document
|
||||
echo $html;
|
||||
?>
|
||||
</body>
|
||||
</html>
|
31
vendor/michelf/php-markdown/composer.json
vendored
Normal file
31
vendor/michelf/php-markdown/composer.json
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"name": "michelf/php-markdown",
|
||||
"type": "library",
|
||||
"description": "PHP Markdown",
|
||||
"homepage": "http://michelf.ca/projects/php-markdown/",
|
||||
"keywords": ["markdown"],
|
||||
"license": "BSD-3-Clause",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michel Fortin",
|
||||
"email": "michel.fortin@michelf.ca",
|
||||
"homepage": "http://michelf.ca/",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "John Gruber",
|
||||
"homepage": "http://daringfireball.net/"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "Michelf": "" }
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-lib": "1.3.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue