[Upg] Use Parsedown instead of PHP-Markdown

This commit is contained in:
Laurent Goussard 2014-05-22 17:41:04 +02:00
parent b2330ad357
commit 15cfd862e9
123 changed files with 3067 additions and 54 deletions

View file

@ -14,7 +14,7 @@
"require": {
"php": ">=5.2.4",
"twig/twig": "1.12.*",
"michelf/php-markdown": "1.3"
"erusev/parsedown-extra": "dev-master@dev"
},
"autoload": {
"files": ["lib/pico.php"]

View file

@ -1,6 +1,4 @@
<?php
use \Michelf\MarkdownExtra;
/**
* Pico
*
@ -138,7 +136,7 @@ class Pico {
{
$content = preg_replace('#/\*.+?\*/#s', '', $content); // Remove comments and meta
$content = str_replace('%base_url%', $this->base_url(), $content);
$content = MarkdownExtra::defaultTransform($content);
$content = (new ParsedownExtra())->text($content);
return $content;
}

2
vendor/autoload.php vendored
View file

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInit68d29614b81b64051229769b084d96b6::getLoader();
return ComposerAutoloaderInit0f07733bc2359d393774afca848003a1::getLoader();

View file

@ -42,19 +42,36 @@ namespace Composer\Autoload;
*/
class ClassLoader
{
private $prefixes = array();
private $fallbackDirs = array();
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
public function getPrefixes()
{
return call_user_func_array('array_merge', $this->prefixes);
return call_user_func_array('array_merge', $this->prefixesPsr0);
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirs;
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
@ -75,23 +92,24 @@ class ClassLoader
}
/**
* Registers a set of classes, merging with any others previously set.
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The classes prefix
* @param array|string $paths The location(s) of the classes
* @param bool $prepend Prepend the location(s)
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirs = array_merge(
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirs
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirs = array_merge(
$this->fallbackDirs,
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
@ -100,38 +118,104 @@ class ClassLoader
}
$first = $prefix[0];
if (!isset($this->prefixes[$first][$prefix])) {
$this->prefixes[$first][$prefix] = (array) $paths;
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixes[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixes[$first][$prefix]
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixes[$first][$prefix] = array_merge(
$this->prefixes[$first][$prefix],
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of classes, replacing any others previously set.
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The classes prefix
* @param array|string $paths The location(s) of the classes
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-0 base directories
* @param bool $prepend Whether to prepend the directories
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirs = (array) $paths;
return;
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
*/
public function setPsr4($prefix, $paths) {
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
$this->prefixes[substr($prefix, 0, 1)][$prefix] = (array) $paths;
}
/**
@ -182,7 +266,7 @@ class ClassLoader
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
include $file;
includeFile($file);
return true;
}
@ -202,45 +286,93 @@ class ClassLoader
$class = substr($class, 1);
}
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$classPath = strtr(substr($class, 0, $pos), '\\', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$className = substr($class, $pos + 1);
} else {
// PEAR-like class name
$classPath = null;
$className = $class;
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if ($file === null && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
$classPath .= strtr($className, '_', DIRECTORY_SEPARATOR) . '.php';
if ($file === null) {
// Remember that this class does not exist.
return $this->classMap[$class] = false;
}
return $file;
}
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixes[$first])) {
foreach ($this->prefixes[$first] as $prefix => $dirs) {
if (isset($this->prefixLengthsPsr4[$first])) {
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
return $dir . DIRECTORY_SEPARATOR . $classPath;
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
return $file;
}
}
}
}
}
foreach ($this->fallbackDirs as $dir) {
if (file_exists($dir . DIRECTORY_SEPARATOR . $classPath)) {
return $dir . DIRECTORY_SEPARATOR . $classPath;
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
if ($this->useIncludePath && $file = stream_resolve_include_path($classPath)) {
return $file;
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
return $this->classMap[$class] = false;
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}

10
vendor/composer/autoload_files.php vendored Normal file
View file

@ -0,0 +1,10 @@
<?php
// autoload_files.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
$baseDir . '/lib/pico.php',
);

View file

@ -7,5 +7,7 @@ $baseDir = dirname($vendorDir);
return array(
'Twig_' => array($vendorDir . '/twig/twig/lib'),
'ParsedownExtra' => array($vendorDir . '/erusev/parsedown-extra'),
'Parsedown' => array($vendorDir . '/erusev/parsedown'),
'Michelf' => array($vendorDir . '/michelf/php-markdown'),
);

9
vendor/composer/autoload_psr4.php vendored Normal file
View file

@ -0,0 +1,9 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

View file

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit68d29614b81b64051229769b084d96b6
class ComposerAutoloaderInit0f07733bc2359d393774afca848003a1
{
private static $loader;
@ -19,9 +19,9 @@ class ComposerAutoloaderInit68d29614b81b64051229769b084d96b6
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit68d29614b81b64051229769b084d96b6', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit0f07733bc2359d393774afca848003a1', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit68d29614b81b64051229769b084d96b6', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit0f07733bc2359d393774afca848003a1', 'loadClassLoader'));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
@ -31,6 +31,11 @@ class ComposerAutoloaderInit68d29614b81b64051229769b084d96b6
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
@ -38,6 +43,16 @@ class ComposerAutoloaderInit68d29614b81b64051229769b084d96b6
$loader->register(true);
$includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) {
composerRequire0f07733bc2359d393774afca848003a1($file);
}
return $loader;
}
}
function composerRequire0f07733bc2359d393774afca848003a1($file)
{
require $file;
}

View file

@ -102,5 +102,92 @@
"keywords": [
"markdown"
]
},
{
"name": "erusev/parsedown",
"version": "1.0.1",
"version_normalized": "1.0.1.0",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown.git",
"reference": "d24439ada0704948deef0d3eda2ea20fd8db1747"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/d24439ada0704948deef0d3eda2ea20fd8db1747",
"reference": "d24439ada0704948deef0d3eda2ea20fd8db1747",
"shasum": ""
},
"time": "2014-05-21 20:20:46",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"Parsedown": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"description": "Parser for Markdown.",
"homepage": "http://parsedown.org",
"keywords": [
"markdown",
"parser"
]
},
{
"name": "erusev/parsedown-extra",
"version": "dev-master",
"version_normalized": "9999999-dev",
"source": {
"type": "git",
"url": "https://github.com/erusev/parsedown-extra.git",
"reference": "032a244dd7cae4f1562e9ff6e23a9fcba75c9e56"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown-extra/zipball/032a244dd7cae4f1562e9ff6e23a9fcba75c9e56",
"reference": "032a244dd7cae4f1562e9ff6e23a9fcba75c9e56",
"shasum": ""
},
"require": {
"erusev/parsedown": "~1.0"
},
"time": "2014-05-14 17:04:59",
"type": "library",
"installation-source": "source",
"autoload": {
"psr-0": {
"ParsedownExtra": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"description": "An extension of Parsedown that adds support for Markdown Extra.",
"homepage": "https://github.com/erusev/parsedown-extra",
"keywords": [
"markdown",
"markdown extra",
"parsedown",
"parser"
]
}
]

View file

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 Emanuil Rusev, erusev.com
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,371 @@
<?php
#
#
# Parsedown Extra
# https://github.com/erusev/parsedown-extra
#
# (c) Emanuil Rusev
# http://erusev.com
#
# For the full license information, view the LICENSE file that was distributed
# with this source code.
#
#
class ParsedownExtra extends Parsedown
{
#
# ~
function __construct()
{
$this->BlockTypes[':'] []= 'DefinitionList';
$this->DefinitionTypes['*'] []= 'Abbreviation';
# identify footnote definitions before reference definitions
array_unshift($this->DefinitionTypes['['], 'Footnote');
# identify footnote markers before before links
array_unshift($this->SpanTypes['['], 'FootnoteMarker');
}
#
# ~
function text($text)
{
$markup = parent::text($text);
# merge consecutive dl elements
$markup = preg_replace('/<\/dl>\s+<dl>\s+/', '', $markup);
# add footnotes
if (isset($this->Definitions['Footnote']))
{
$Element = $this->buildFootnoteElement();
$markup .= "\n" . $this->element($Element);
}
return $markup;
}
#
# Blocks
#
#
# Atx
protected function identifyAtx($Line)
{
$Block = parent::identifyAtx($Line);
if (preg_match('/[ ]*'.$this->attributesPattern.'[ ]*$/', $Block['element']['text'], $matches, PREG_OFFSET_CAPTURE))
{
$attributeString = $matches[1][0];
$Block['element']['attributes'] = $this->parseAttributes($attributeString);
$Block['element']['text'] = substr($Block['element']['text'], 0, $matches[0][1]);
}
return $Block;
}
#
# Definition List
protected function identifyDefinitionList($Line, $Block)
{
if (isset($Block['type']))
{
return;
}
$Element = array(
'name' => 'dl',
'handler' => 'elements',
'text' => array(),
);
$terms = explode("\n", $Block['element']['text']);
foreach ($terms as $term)
{
$Element['text'] []= array(
'name' => 'dt',
'handler' => 'line',
'text' => $term,
);
}
$Element['text'] []= array(
'name' => 'dd',
'handler' => 'line',
'text' => ltrim($Line['text'], ' :'),
);
$Block['element'] = $Element;
return $Block;
}
protected function addToDefinitionList($Line, array $Block)
{
if ($Line['text'][0] === ':')
{
$Block['element']['text'] []= array(
'name' => 'dd',
'handler' => 'line',
'text' => ltrim($Line['text'], ' :'),
);
return $Block;
}
if ( ! isset($Block['interrupted']))
{
$Element = array_pop($Block['element']['text']);
$Element['text'] .= "\n" . chop($Line['text']);
$Block['element']['text'] []= $Element;
return $Block;
}
}
#
# Setext
protected function identifySetext($Line, array $Block = null)
{
$Block = parent::identifySetext($Line, $Block);
if (preg_match('/[ ]*'.$this->attributesPattern.'[ ]*$/', $Block['element']['text'], $matches, PREG_OFFSET_CAPTURE))
{
$attributeString = $matches[1][0];
$Block['element']['attributes'] = $this->parseAttributes($attributeString);
$Block['element']['text'] = substr($Block['element']['text'], 0, $matches[0][1]);
}
return $Block;
}
#
# Definitions
#
#
# Abbreviation
protected function identifyAbbreviation($Line)
{
if (preg_match('/^\*\[(.+?)\]:[ ]*(.+?)[ ]*$/', $Line['text'], $matches))
{
$Abbreviation = array(
'id' => $matches[1],
'data' => $matches[2],
);
return $Abbreviation;
}
}
#
# Footnote
protected function identifyFootnote($Line)
{
if (preg_match('/^\[\^(.+?)\]:[ ]?(.+)$/', $Line['text'], $matches))
{
$Footnote = array(
'id' => $matches[1],
'data' => array(
'text' => $matches[2],
'count' => null,
'number' => null,
),
);
return $Footnote;
}
}
#
# Spans
#
#
# Footnote Marker
protected function identifyFootnoteMarker($Excerpt)
{
if (preg_match('/^\[\^(.+?)\]/', $Excerpt['text'], $matches))
{
$name = $matches[1];
if ( ! isset($this->Definitions['Footnote'][$name]))
{
return;
}
$this->Definitions['Footnote'][$name]['count'] ++;
if ( ! isset($this->Definitions['Footnote'][$name]['number']))
{
$this->Definitions['Footnote'][$name]['number'] = ++ $this->footnoteCount; # » &
}
$Element = array(
'name' => 'sup',
'attributes' => array('id' => 'fnref'.$this->Definitions['Footnote'][$name]['count'].':'.$name),
'handler' => 'element',
'text' => array(
'name' => 'a',
'attributes' => array('href' => '#fn:'.$name, 'class' => 'footnote-ref'),
'text' => $this->Definitions['Footnote'][$name]['number'],
),
);
return array(
'extent' => strlen($matches[0]),
'element' => $Element,
);
}
}
private $footnoteCount = 0;
#
# Link
protected function identifyLink($Excerpt)
{
$Span = parent::identifyLink($Excerpt);
$remainder = substr($Excerpt['text'], $Span['extent']);
if (preg_match('/^[ ]*'.$this->attributesPattern.'/', $remainder, $matches))
{
$Span['element']['attributes'] += $this->parseAttributes($matches[1]);
$Span['extent'] += strlen($matches[0]);
}
return $Span;
}
#
# ~
protected function readPlainText($text)
{
$text = parent::readPlainText($text);
if (isset($this->Definitions['Abbreviation']))
{
foreach ($this->Definitions['Abbreviation'] as $abbreviation => $phrase)
{
$text = str_replace($abbreviation, '<abbr title="'.$phrase.'">'.$abbreviation.'</abbr>', $text);
}
}
return $text;
}
#
# ~
#
protected function buildFootnoteElement()
{
$Element = array(
'name' => 'div',
'attributes' => array('class' => 'footnotes'),
'handler' => 'elements',
'text' => array(
array(
'name' => 'hr',
),
array(
'name' => 'ol',
'handler' => 'elements',
'text' => array(),
),
),
);
usort($this->Definitions['Footnote'], function($A, $B) {
return $A['number'] - $B['number'];
});
foreach ($this->Definitions['Footnote'] as $name => $Data)
{
if ( ! isset($Data['number']))
{
continue;
}
$text = $Data['text'];
foreach (range(1, $Data['count']) as $number)
{
$text .= '&#160;<a href="#fnref'.$number.':'.$name.'" rev="footnote" class="footnote-backref">&#8617;</a>';
}
$Element['text'][1]['text'] []= array(
'name' => 'li',
'attributes' => array('id' => 'fn:'.$name),
'handler' => 'elements',
'text' => array(
array(
'name' => 'p',
'text' => $text,
),
),
);
}
return $Element;
}
#
# Private
#
private function parseAttributes($attributeString)
{
$Data = array();
$attributes = preg_split('/[ ]+/', $attributeString, - 1, PREG_SPLIT_NO_EMPTY);
foreach ($attributes as $attribute)
{
if ($attribute[0] === '#')
{
$Data['id'] = substr($attribute, 1);
}
else # "."
{
$classes []= substr($attribute, 1);
}
}
if (isset($classes))
{
$Data['class'] = implode(' ', $classes);
}
return $Data;
}
private $attributesPattern = '{((?:[#.][-\w]+[ ]*)+)}';
}

15
vendor/erusev/parsedown-extra/README.md vendored Normal file
View file

@ -0,0 +1,15 @@
## Parsedown Extra
An extension of [Parsedown](http://parsedown.org) that adds support for [Markdown Extra](http://en.wikipedia.org/wiki/Markdown_Extra).
### Installation
Include both `Parsedown.php` and `ParsedownExtra.php` or install [the composer package](https://packagist.org/packages/erusev/parsedown-extra).
### Example
``` php
$Instance = new ParsedownExtra();
echo $Instance->text('Hello _Parsedown Extra_!'); # prints: <p>Hello <em>Parsedown Extra</em>!</p>
```

View file

@ -0,0 +1,21 @@
{
"name": "erusev/parsedown-extra",
"description": "An extension of Parsedown that adds support for Markdown Extra.",
"keywords": ["markdown", "markdown extra", "parser", "parsedown"],
"homepage": "https://github.com/erusev/parsedown-extra",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"require": {
"erusev/parsedown": "~1.0"
},
"autoload": {
"psr-0": {"ParsedownExtra": ""}
}
}

10
vendor/erusev/parsedown/.travis.yml vendored Normal file
View file

@ -0,0 +1,10 @@
language: php
php:
- 5.6
- 5.5
- 5.4
- 5.3
- 5.2
- hhvm

20
vendor/erusev/parsedown/LICENSE.txt vendored Normal file
View file

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 Emanuil Rusev, erusev.com
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1402
vendor/erusev/parsedown/Parsedown.php vendored Executable file

File diff suppressed because it is too large Load diff

40
vendor/erusev/parsedown/README.md vendored Normal file
View file

@ -0,0 +1,40 @@
## Parsedown
Better [Markdown](http://en.wikipedia.org/wiki/Markdown) parser for PHP.
* [Demo](http://parsedown.org/demo)
* [Test Suite](http://parsedown.org/tests/)
### Features
* [Fast](http://parsedown.org/speed)
* [Consistent](http://parsedown.org/consistency)
* [GitHub Flavored](https://help.github.com/articles/github-flavored-markdown)
* [Tested](https://travis-ci.org/erusev/parsedown) in PHP 5.2, 5.3, 5.4, 5.5, 5.6 and [hhvm](http://www.hhvm.com/)
* Extensible
* [Markdown Extra extension](https://github.com/erusev/parsedown-extra) <sup>new</sup>
### Installation
Include `Parsedown.php` or install [the composer package](https://packagist.org/packages/erusev/parsedown).
### Example
``` php
$Parsedown = new Parsedown();
echo $Parsedown->text('Hello _Parsedown_!'); # prints: <p>Hello <em>Parsedown</em>!</p>
```
More examples in [the wiki](https://github.com/erusev/parsedown/wiki/Usage).
### Questions
**How does Parsedown work?**<br/>
Parsedown recognises that the Markdown syntax is optimised for humans so it tries to read like one. It goes through text line by line. It looks at how lines start to identify blocks. It looks for special characters to identify inline elements.
**Why doesnt Parsedown use namespaces?**<br/>
Using namespaces would mean dropping support for PHP 5.2. Since Parsedown is a single class with an uncommon name, making this trade wouldn't make much sense.
**Who uses Parsedown?**<br/>
[phpDocumentor](http://www.phpdoc.org/), [Bolt CMS](http://bolt.cm/), [RaspberryPi.org](http://www.raspberrypi.org/) and [more](https://www.versioneye.com/php/erusev:parsedown/references).

18
vendor/erusev/parsedown/composer.json vendored Normal file
View file

@ -0,0 +1,18 @@
{
"name": "erusev/parsedown",
"description": "Parser for Markdown.",
"keywords": ["markdown", "parser"],
"homepage": "http://parsedown.org",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"autoload": {
"psr-0": {"Parsedown": ""}
}
}

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="test/bootstrap.php" colors="true">
<testsuites>
<testsuite>
<file>test/Test.php</file>
</testsuite>
</testsuites>
</phpunit>

65
vendor/erusev/parsedown/test/Test.php vendored Normal file
View file

@ -0,0 +1,65 @@
<?php
class Test extends PHPUnit_Framework_TestCase
{
public function __construct($name = null, array $data = array(), $dataName = '')
{
$this->dataDir = dirname(__FILE__).'/data/';
parent::__construct($name, $data, $dataName);
}
private $dataDir;
/**
* @dataProvider data
*/
function test_($filename)
{
$markdown = file_get_contents($this->dataDir . $filename . '.md');
$expectedMarkup = file_get_contents($this->dataDir . $filename . '.html');
$expectedMarkup = str_replace("\r\n", "\n", $expectedMarkup);
$expectedMarkup = str_replace("\r", "\n", $expectedMarkup);
$actualMarkup = Parsedown::instance()->text($markdown);
$this->assertEquals($expectedMarkup, $actualMarkup);
}
function data()
{
$data = array();
$Folder = new DirectoryIterator($this->dataDir);
foreach ($Folder as $File)
{
/** @var $File DirectoryIterator */
if ( ! $File->isFile())
{
continue;
}
$filename = $File->getFilename();
$extension = pathinfo($filename, PATHINFO_EXTENSION);
if ($extension !== 'md')
{
continue;
}
$basename = $File->getBasename('.md');
if (file_exists($this->dataDir . $basename . '.html'))
{
$data []= array($basename);
}
}
return $data;
}
}

View file

@ -0,0 +1,3 @@
<?php
include 'Parsedown.php';

View file

@ -0,0 +1,5 @@
<!-- single line -->
<p>paragraph</p>
<!--
multiline -->
<p>paragraph</p>

View file

@ -0,0 +1,8 @@
<!-- single line -->
paragraph
<!--
multiline -->
paragraph

View file

@ -0,0 +1,18 @@
<table>
<thead>
<tr>
<th>header 1</th>
<th>header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>cell 1.1</td>
<td>cell 1.2</td>
</tr>
<tr>
<td>cell 2.1</td>
<td>cell 2.2</td>
</tr>
</tbody>
</table>

View file

@ -0,0 +1,4 @@
| header 1 | header 2 |
| -------- | -------- |
| cell 1.1 | cell 1.2 |
| cell 2.1 | cell 2.2 |

View file

@ -0,0 +1,21 @@
<table>
<thead>
<tr>
<th align="left">header 1</th>
<th align="center">header 2</th>
<th align="right">header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">cell 1.1</td>
<td align="center">cell 1.2</td>
<td align="right">cell 1.3</td>
</tr>
<tr>
<td align="left">cell 2.1</td>
<td align="center">cell 2.2</td>
<td align="right">cell 2.3</td>
</tr>
</tbody>
</table>

View file

@ -0,0 +1,4 @@
| header 1 | header 2 | header 2 |
| :------- | :------: | -------: |
| cell 1.1 | cell 1.2 | cell 1.3 |
| cell 2.1 | cell 2.2 | cell 2.3 |

View file

@ -0,0 +1,8 @@
<h1>h1</h1>
<h2>h2</h2>
<h3>h3</h3>
<h4>h4</h4>
<h5>h5</h5>
<h6>h6</h6>
<h1>closed h1</h1>
<p>#</p>

View file

@ -0,0 +1,15 @@
# h1
## h2
### h3
#### h4
##### h5
###### h6
# closed h1 #
#

View file

@ -0,0 +1 @@
<p><a href="http://example.com">http://example.com</a></p>

View file

@ -0,0 +1 @@
<http://example.com>

View file

@ -0,0 +1,8 @@
<div>_content_</div>
<p>sparse:</p>
<div>
<div class="inner">
_content_
</div>
</div>
<p>paragraph</p>

View file

@ -0,0 +1,11 @@
<div>_content_</div>
sparse:
<div>
<div class="inner">
_content_
</div>
</div>
paragraph

View file

@ -0,0 +1,8 @@
<pre><code>&lt;?php
$message = 'Hello World!';
echo $message;</code></pre>
<hr />
<pre><code>&gt; not a quote
- not a list item
[not a reference]: http://foo.com</code></pre>

View file

@ -0,0 +1,10 @@
<?php
$message = 'Hello World!';
echo $message;
---
> not a quote
- not a list item
[not a reference]: http://foo.com

View file

@ -0,0 +1,6 @@
<p>a <code>code span</code></p>
<p><code>this is also a codespan</code> trailing text</p>
<p><code>and look at this one!</code></p>
<p>single backtick in a code span: <code>`</code></p>
<p>backtick-delimited string in a code span: <code>`foo`</code></p>
<p><code>sth `` sth</code></p>

View file

@ -0,0 +1,11 @@
a `code span`
`this is also a codespan` trailing text
`and look at this one!`
single backtick in a code span: `` ` ``
backtick-delimited string in a code span: `` `foo` ``
`sth `` sth`

View file

@ -0,0 +1,9 @@
<blockquote>
<h2>header</h2>
<p>paragraph</p>
<ul>
<li>li</li>
</ul>
<hr />
<p>paragraph</p>
</blockquote>

View file

@ -0,0 +1,10 @@
> header
> ------
>
> paragraph
>
> - li
>
> ---
>
> paragraph

View file

@ -0,0 +1,2 @@
<p><em><code>code</code></em> <strong><code>code</code></strong></p>
<p><em><code>code</code><strong><code>code</code></strong><code>code</code></em></p>

View file

@ -0,0 +1,4 @@
_`code`_ __`code`__
*`code`**`code`**`code`*

View file

@ -0,0 +1,12 @@
<ul>
<li>
<p>paragraph</p>
<p>paragraph</p>
</li>
<li>
<p>paragraph</p>
<blockquote>
<p>quote</p>
</blockquote>
</li>
</ul>

View file

@ -0,0 +1,7 @@
- paragraph
paragraph
- paragraph
> quote

View file

@ -0,0 +1,12 @@
<ul>
<li>li
<ul>
<li>li
<ul>
<li>li</li>
<li>li</li>
</ul></li>
<li>li</li>
</ul></li>
<li>li</li>
</ul>

View file

@ -0,0 +1,6 @@
- li
- li
- li
- li
- li
- li

View file

@ -0,0 +1,8 @@
<p><strong><em>em strong</em></strong></p>
<p><strong><em>em strong</em> strong</strong></p>
<p><strong>strong <em>em strong</em></strong></p>
<p><strong>strong <em>em strong</em> strong</strong></p>
<p><strong><em>em strong</em></strong></p>
<p><strong><em>em strong</em> strong</strong></p>
<p><strong>strong <em>em strong</em></strong></p>
<p><strong>strong <em>em strong</em> strong</strong></p>

View file

@ -0,0 +1,15 @@
___em strong___
___em strong_ strong__
__strong _em strong___
__strong _em strong_ strong__
***em strong***
***em strong* strong**
**strong *em strong***
**strong *em strong* strong**

View file

@ -0,0 +1 @@
<p>my email is <a href="mailto:me@example.com">me@example.com</a></p>

View file

@ -0,0 +1 @@
my email is <me@example.com>

View file

@ -0,0 +1,8 @@
<p><em>underscore</em>, <em>asterisk</em>, <em>one two</em>, <em>three four</em>, <em>a</em>, <em>b</em></p>
<p><strong>strong</strong> and <em>em</em> and <strong>strong</strong> and <em>em</em></p>
<p><em>line
line
line</em></p>
<p>this_is_not_an_emphasis</p>
<p>an empty emphasis __ ** is not an emphasis</p>
<p>*mixed *<em>double and</em> single asterisk** spans</p>

View file

@ -0,0 +1,13 @@
_underscore_, *asterisk*, _one two_, *three four*, _a_, *b*
**strong** and *em* and **strong** and *em*
_line
line
line_
this_is_not_an_emphasis
an empty emphasis __ ** is not an emphasis
*mixed **double and* single asterisk** spans

View file

@ -0,0 +1,4 @@
<p>escaped *emphasis*.</p>
<p><code>escaped \*emphasis\* in a code span</code></p>
<pre><code>escaped \*emphasis\* in a code block</code></pre>
<p>\ ` * _ { } [ ] ( ) > # + - . !</p>

View file

@ -0,0 +1,7 @@
escaped \*emphasis\*.
`escaped \*emphasis\* in a code span`
escaped \*emphasis\* in a code block
\\ \` \* \_ \{ \} \[ \] \( \) \> \# \+ \- \. \!

View file

@ -0,0 +1,6 @@
<pre><code>&lt;?php
$message = 'fenced code block';
echo $message;</code></pre>
<pre><code>tilde</code></pre>
<pre><code class="language-php">echo 'language identifier';</code></pre>

View file

@ -0,0 +1,14 @@
```
<?php
$message = 'fenced code block';
echo $message;
```
~~~
tilde
~~~
```php
echo 'language identifier';
```

View file

@ -0,0 +1,5 @@
<hr />
<hr />
<hr />
<hr />
<hr />

View file

@ -0,0 +1,9 @@
---
- - -
- - -
***
___

View file

@ -0,0 +1 @@
<p>&amp; &copy; &#123;</p>

View file

@ -0,0 +1 @@
&amp; &copy; &#123;

View file

@ -0,0 +1 @@
<p><img alt="Markdown Logo" src="/md.png" /></p>

View file

@ -0,0 +1,3 @@
![Markdown Logo][image]
[image]: /md.png

View file

@ -0,0 +1 @@
<p><img alt="alt" src="/md.png" title="title" /></p>

View file

@ -0,0 +1 @@
![alt](/md.png "title")

View file

@ -0,0 +1,4 @@
<p>an <a href="http://example.com">implicit</a> reference link</p>
<p>an <a href="http://example.com">implicit</a> reference link with an empty link definition</p>
<p>an <a href="http://example.com">implicit</a> reference link followed by <a href="http://cnn.com">another</a></p>
<p>an <a href="http://example.com" title="Example">explicit</a> reference link with a title</p>

View file

@ -0,0 +1,13 @@
an [implicit] reference link
[implicit]: http://example.com
an [implicit][] reference link with an empty link definition
an [implicit][] reference link followed by [another][]
[another]: http://cnn.com
an [explicit][example] reference link with a title
[example]: http://example.com "Example"

View file

@ -0,0 +1,4 @@
<p><a href="http://example.com">link</a> and <a href="/tests/">another link</a></p>
<p><a href="http://example.com"><code>link</code></a></p>
<p><a href="http://example.com"><img alt="MD Logo" src="http://parsedown.org/md.png" /></a></p>
<p><a href="http://example.com"><img alt="MD Logo" src="http://parsedown.org/md.png" /> and text</a></p>

View file

@ -0,0 +1,7 @@
[link](http://example.com) and [another link](/tests/)
[`link`](http://example.com)
[![MD Logo](http://parsedown.org/md.png)](http://example.com)
[![MD Logo](http://parsedown.org/md.png) and text](http://example.com)

View file

@ -0,0 +1 @@
<p><a href="http://example.com" title="Title">single quotes</a> and <a href="http://example.com" title="Title">double quotes</a></p>

View file

@ -0,0 +1 @@
[single quotes](http://example.com 'Title') and [double quotes](http://example.com "Title")

View file

@ -0,0 +1 @@
<p><a href="http://example.com" title="Example">single quotes</a> and <a href="http://example.com" title="Example">double quotes</a></p>

View file

@ -0,0 +1 @@
[single quotes](http://example.com 'Example') and [double quotes](http://example.com "Example")

View file

@ -0,0 +1,6 @@
<blockquote>
<p>quote
the rest of it</p>
<p>another paragraph
the rest of it</p>
</blockquote>

View file

@ -0,0 +1,5 @@
> quote
the rest of it
> another paragraph
the rest of it

View file

@ -0,0 +1,4 @@
<ul>
<li>li
the rest of it</li>
</ul>

View file

@ -0,0 +1,2 @@
- li
the rest of it

View file

@ -0,0 +1,2 @@
<p>line<br />
line</p>

View file

@ -0,0 +1,2 @@
line
line

View file

@ -0,0 +1,7 @@
<ul>
<li>
<p>li</p>
<p>line
line</p>
</li>
</ul>

View file

@ -0,0 +1,4 @@
- li
line
line

View file

@ -0,0 +1,10 @@
<div>
_parent_
<div>
_child_
</div>
<pre>
_adopted child_
</pre>
</div>
<p><em>outside</em></p>

View file

@ -0,0 +1,11 @@
<div>
_parent_
<div>
_child_
</div>
<pre>
_adopted child_
</pre>
</div>
_outside_

View file

@ -0,0 +1,13 @@
<ol>
<li>one</li>
<li>two</li>
</ol>
<p>repeating numbers:</p>
<ol>
<li>one</li>
<li>two</li>
</ol>
<p>large numbers:</p>
<ol>
<li>one</li>
</ol>

View file

@ -0,0 +1,11 @@
1. one
2. two
repeating numbers:
1. one
1. two
large numbers:
123. one

View file

@ -0,0 +1,12 @@
<p>paragraph</p>
<ul>
<li>li</li>
<li>li</li>
</ul>
<p>paragraph</p>
<ul>
<li>
<p>li</p>
</li>
<li>li</li>
</ul>

View file

@ -0,0 +1,9 @@
paragraph
- li
- li
paragraph
* li
* li

View file

@ -0,0 +1,2 @@
<p><a href="http://example.com" title="example title">double quotes</a> and <a href="http://example.com" title="example title">single quotes</a> and <a href="http://example.com" title="example title">parentheses</a></p>
<p>[invalid title]: <a href="http://example.com">http://example.com</a> example title</p>

View file

@ -0,0 +1,6 @@
[double quotes] and [single quotes] and [parentheses]
[double quotes]: http://example.com "example title"
[single quotes]: http://example.com 'example title'
[parentheses]: http://example.com (example title)
[invalid title]: http://example.com example title

View file

@ -0,0 +1,12 @@
<hr>
<p>paragraph</p>
<hr/>
<p>paragraph</p>
<hr />
<p>paragraph</p>
<hr class="foo" id="bar" />
<p>paragraph</p>
<hr class="foo" id="bar"/>
<p>paragraph</p>
<hr class="foo" id="bar" >
<p>paragraph</p>

View file

@ -0,0 +1,12 @@
<hr>
paragraph
<hr/>
paragraph
<hr />
paragraph
<hr class="foo" id="bar" />
paragraph
<hr class="foo" id="bar"/>
paragraph
<hr class="foo" id="bar" >
paragraph

View file

@ -0,0 +1,9 @@
<ul>
<li>
<p>li</p>
<ul>
<li>li</li>
<li>li</li>
</ul>
</li>
</ul>

View file

@ -0,0 +1,4 @@
- li
- li
- li

View file

@ -0,0 +1,5 @@
<h1>h1</h1>
<h2>h2</h2>
<h2>single character</h2>
<p>not a header</p>
<hr />

View file

@ -0,0 +1,12 @@
h1
==
h2
--
single character
-
not a header
------------

View file

@ -0,0 +1,11 @@
<blockquote>
<p>quote</p>
</blockquote>
<p>indented:</p>
<blockquote>
<p>quote</p>
</blockquote>
<p>no space after <code>&gt;</code>:</p>
<blockquote>
<p>quote</p>
</blockquote>

View file

@ -0,0 +1,7 @@
> quote
indented:
> quote
no space after `>`:
>quote

View file

@ -0,0 +1,37 @@
<table>
<thead>
<tr>
<th>header 1</th>
<th>header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>cell 1.1</td>
<td>cell 1.2</td>
</tr>
<tr>
<td>cell 2.1</td>
<td>cell 2.2</td>
</tr>
</tbody>
</table>
<hr />
<table>
<thead>
<tr>
<th align="left">header 1</th>
<th>header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">cell 1.1</td>
<td>cell 1.2</td>
</tr>
<tr>
<td align="left">cell 2.1</td>
<td>cell 2.2</td>
</tr>
</tbody>
</table>

View file

@ -0,0 +1,11 @@
header 1 | header 2
-------- | --------
cell 1.1 | cell 1.2
cell 2.1 | cell 2.2
---
header 1 | header 2
:------- | --------
cell 1.1 | cell 1.2
cell 2.1 | cell 2.2

View file

@ -0,0 +1,5 @@
<p>an <b>important</b> <a href=''>link</a></p>
<p>broken<br/>
line</p>
<p><b>inline tag</b> at the beginning</p>
<p><span><a href="http://example.com">http://example.com</a></span></p>

View file

@ -0,0 +1,8 @@
an <b>important</b> <a href=''>link</a>
broken<br/>
line
<b>inline tag</b> at the beginning
<span>http://example.com</span>

View file

@ -0,0 +1,7 @@
<ul>
<li>
<p>li</p>
</li>
<li>li</li>
<li>li</li>
</ul>

Some files were not shown because too many files have changed in this diff Show more