Upgrading Parsedown to 1.0.0 and removing Tests

This commit is contained in:
Denis Kisselev 2014-05-17 11:16:40 -07:00
parent 8681ec1a80
commit da0cc07392
110 changed files with 368 additions and 1129 deletions

View File

@ -13,6 +13,6 @@
], ],
"require": { "require": {
"php": ">=5.3", "php": ">=5.3",
"erusev/parsedown": "dev-master" "erusev/parsedown": "1.0.0"
} }
} }

18
composer.lock generated
View File

@ -3,20 +3,20 @@
"This file locks the dependencies of your project to a known state", "This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
], ],
"hash": "316e27cc72bce34db33fdde3d1b1c414", "hash": "21bea6f01fcb0695632cbacb5a3988a1",
"packages": [ "packages": [
{ {
"name": "erusev/parsedown", "name": "erusev/parsedown",
"version": "dev-master", "version": "1.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/erusev/parsedown.git", "url": "https://github.com/erusev/parsedown.git",
"reference": "60819541858f9da6fcb77e8bd09693635553d3ef" "reference": "2da10d277b086372f17b96df6cdc903829e1dde0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/60819541858f9da6fcb77e8bd09693635553d3ef", "url": "https://api.github.com/repos/erusev/parsedown/zipball/2da10d277b086372f17b96df6cdc903829e1dde0",
"reference": "60819541858f9da6fcb77e8bd09693635553d3ef", "reference": "2da10d277b086372f17b96df6cdc903829e1dde0",
"shasum": "" "shasum": ""
}, },
"type": "library", "type": "library",
@ -42,7 +42,7 @@
"markdown", "markdown",
"parser" "parser"
], ],
"time": "2014-04-17 21:19:22" "time": "2014-05-14 10:14:49"
} }
], ],
"packages-dev": [ "packages-dev": [
@ -52,9 +52,9 @@
], ],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": { "stability-flags": [
"erusev/parsedown": 20
}, ],
"platform": { "platform": {
"php": ">=5.3" "php": ">=5.3"
}, },

2
vendor/autoload.php vendored
View File

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

View File

@ -291,25 +291,8 @@ class ClassLoader
return $this->classMap[$class]; return $this->classMap[$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');
}
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 // PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . '.php';
$first = $class[0]; $first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) { if (isset($this->prefixLengthsPsr4[$first])) {
@ -338,7 +321,7 @@ class ClassLoader
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else { } else {
// PEAR-like class name // PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . '.php';
} }
if (isset($this->prefixesPsr0[$first])) { if (isset($this->prefixesPsr0[$first])) {
@ -364,6 +347,9 @@ class ClassLoader
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file; return $file;
} }
// Remember that this class does not exist.
return $this->classMap[$class] = false;
} }
} }

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer // autoload_real.php @generated by Composer
class ComposerAutoloaderInitc4f9f971364586e3674cb9fcd0600bab class ComposerAutoloaderInit73a81d925b42f1d439aed1c696b3e22d
{ {
private static $loader; private static $loader;
@ -19,9 +19,9 @@ class ComposerAutoloaderInitc4f9f971364586e3674cb9fcd0600bab
return self::$loader; return self::$loader;
} }
spl_autoload_register(array('ComposerAutoloaderInitc4f9f971364586e3674cb9fcd0600bab', 'loadClassLoader'), true, true); spl_autoload_register(array('ComposerAutoloaderInit73a81d925b42f1d439aed1c696b3e22d', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(); self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitc4f9f971364586e3674cb9fcd0600bab', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInit73a81d925b42f1d439aed1c696b3e22d', 'loadClassLoader'));
$vendorDir = dirname(__DIR__); $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir); $baseDir = dirname($vendorDir);
@ -47,7 +47,7 @@ class ComposerAutoloaderInitc4f9f971364586e3674cb9fcd0600bab
} }
} }
function composerRequirec4f9f971364586e3674cb9fcd0600bab($file) function composerRequire73a81d925b42f1d439aed1c696b3e22d($file)
{ {
require $file; require $file;
} }

View File

@ -1,22 +1,22 @@
[ [
{ {
"name": "erusev/parsedown", "name": "erusev/parsedown",
"version": "dev-master", "version": "1.0.0",
"version_normalized": "9999999-dev", "version_normalized": "1.0.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/erusev/parsedown.git", "url": "https://github.com/erusev/parsedown.git",
"reference": "60819541858f9da6fcb77e8bd09693635553d3ef" "reference": "2da10d277b086372f17b96df6cdc903829e1dde0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/erusev/parsedown/zipball/60819541858f9da6fcb77e8bd09693635553d3ef", "url": "https://api.github.com/repos/erusev/parsedown/zipball/2da10d277b086372f17b96df6cdc903829e1dde0",
"reference": "60819541858f9da6fcb77e8bd09693635553d3ef", "reference": "2da10d277b086372f17b96df6cdc903829e1dde0",
"shasum": "" "shasum": ""
}, },
"time": "2014-04-17 21:19:22", "time": "2014-05-14 10:14:49",
"type": "library", "type": "library",
"installation-source": "source", "installation-source": "dist",
"autoload": { "autoload": {
"psr-0": { "psr-0": {
"Parsedown": "" "Parsedown": ""

View File

@ -7,3 +7,4 @@ php:
- 5.3 - 5.3
- 5.2 - 5.2
- hhvm - hhvm

View File

@ -29,6 +29,9 @@ class Parsedown
function text($text) function text($text)
{ {
# make sure no definitions are set
$this->Definitions = array();
# standardize line breaks # standardize line breaks
$text = str_replace("\r\n", "\n", $text); $text = str_replace("\r\n", "\n", $text);
$text = str_replace("\r", "\n", $text); $text = str_replace("\r", "\n", $text);
@ -48,9 +51,6 @@ class Parsedown
# trim line breaks # trim line breaks
$markup = trim($markup, "\n"); $markup = trim($markup, "\n");
# clean up
$this->references = array();
return $markup; return $markup;
} }
@ -58,6 +58,8 @@ class Parsedown
# Setters # Setters
# #
private $breaksEnabled;
function setBreaksEnabled($breaksEnabled) function setBreaksEnabled($breaksEnabled)
{ {
$this->breaksEnabled = $breaksEnabled; $this->breaksEnabled = $breaksEnabled;
@ -65,13 +67,11 @@ class Parsedown
return $this; return $this;
} }
private $breaksEnabled;
# #
# Blocks # Lines
# #
protected $blockMarkers = array( protected $BlockTypes = array(
'#' => array('Atx'), '#' => array('Atx'),
'*' => array('Rule', 'List'), '*' => array('Rule', 'List'),
'+' => array('List'), '+' => array('List'),
@ -87,55 +87,52 @@ class Parsedown
'8' => array('List'), '8' => array('List'),
'9' => array('List'), '9' => array('List'),
':' => array('Table'), ':' => array('Table'),
'<' => array('Markup'), '<' => array('Comment', 'Markup'),
'=' => array('Setext'), '=' => array('Setext'),
'>' => array('Quote'), '>' => array('Quote'),
'[' => array('Reference'),
'_' => array('Rule'), '_' => array('Rule'),
'`' => array('FencedCode'), '`' => array('FencedCode'),
'|' => array('Table'), '|' => array('Table'),
'~' => array('FencedCode'), '~' => array('FencedCode'),
); );
# Draft # ~
protected $definitionMarkers = array(
protected $DefinitionTypes = array(
'[' => array('Reference'), '[' => array('Reference'),
); );
# ~
protected $unmarkedBlockTypes = array( protected $unmarkedBlockTypes = array(
'CodeBlock', 'CodeBlock',
); );
#
# Blocks
#
private function lines(array $lines) private function lines(array $lines)
{ {
$CurrentBlock = null; $CurrentBlock = null;
foreach ($lines as $line) foreach ($lines as $line)
{ {
if (chop($line) === '')
{
if (isset($CurrentBlock))
{
$CurrentBlock['interrupted'] = true;
}
continue;
}
$indent = 0; $indent = 0;
while (true) while (isset($line[$indent]) and $line[$indent] === ' ')
{ {
if (isset($line[$indent])) $indent ++;
{
if ($line[$indent] === ' ')
{
$indent ++;
}
else
{
break;
}
}
else # blank line
{
if (isset($CurrentBlock))
{
$CurrentBlock['interrupted'] = true;
}
continue 2;
}
} }
$text = $indent > 0 ? substr($line, $indent) : $line; $text = $indent > 0 ? substr($line, $indent) : $line;
@ -144,7 +141,7 @@ class Parsedown
$Line = array('body' => $line, 'indent' => $indent, 'text' => $text); $Line = array('body' => $line, 'indent' => $indent, 'text' => $text);
# Multiline block types define "addTo" methods. # ~
if (isset($CurrentBlock['incomplete'])) if (isset($CurrentBlock['incomplete']))
{ {
@ -158,12 +155,31 @@ class Parsedown
} }
else else
{ {
unset($CurrentBlock['incomplete']);
if (method_exists($this, 'complete'.$CurrentBlock['type'])) if (method_exists($this, 'complete'.$CurrentBlock['type']))
{ {
$CurrentBlock = $this->{'complete'.$CurrentBlock['type']}($CurrentBlock); $CurrentBlock = $this->{'complete'.$CurrentBlock['type']}($CurrentBlock);
} }
unset($CurrentBlock['incomplete']);
}
}
# ~
$marker = $text[0];
if (isset($this->DefinitionTypes[$marker]))
{
foreach ($this->DefinitionTypes[$marker] as $definitionType)
{
$Definition = $this->{'identify'.$definitionType}($Line, $CurrentBlock);
if (isset($Definition))
{
$this->Definitions[$definitionType][$Definition['id']] = $Definition['data'];
continue 2;
}
} }
} }
@ -171,11 +187,9 @@ class Parsedown
$blockTypes = $this->unmarkedBlockTypes; $blockTypes = $this->unmarkedBlockTypes;
$marker = $text[0]; if (isset($this->BlockTypes[$marker]))
if (isset($this->blockMarkers[$marker]))
{ {
foreach ($this->blockMarkers[$marker] as $blockType) foreach ($this->BlockTypes[$marker] as $blockType)
{ {
$blockTypes []= $blockType; $blockTypes []= $blockType;
} }
@ -186,23 +200,19 @@ class Parsedown
foreach ($blockTypes as $blockType) foreach ($blockTypes as $blockType)
{ {
# Block types define "identify" methods.
$Block = $this->{'identify'.$blockType}($Line, $CurrentBlock); $Block = $this->{'identify'.$blockType}($Line, $CurrentBlock);
if (isset($Block)) if (isset($Block))
{ {
$Block['type'] = $blockType; $Block['type'] = $blockType;
if ( ! isset($Block['identified'])) # » if ( ! isset($Block['identified']))
{ {
$elements []= $CurrentBlock['element']; $Elements []= $CurrentBlock['element'];
$Block['identified'] = true; $Block['identified'] = true;
} }
# Multiline block types define "addTo" methods.
if (method_exists($this, 'addTo'.$blockType)) if (method_exists($this, 'addTo'.$blockType))
{ {
$Block['incomplete'] = true; $Block['incomplete'] = true;
@ -216,33 +226,36 @@ class Parsedown
# ~ # ~
if ($CurrentBlock['type'] === 'Paragraph' and ! isset($CurrentBlock['interrupted'])) if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted']))
{ {
$CurrentBlock['element']['text'] .= "\n".$text; $CurrentBlock['element']['text'] .= "\n".$text;
} }
else else
{ {
$elements []= $CurrentBlock['element']; $Elements []= $CurrentBlock['element'];
$CurrentBlock = array( $CurrentBlock = $this->buildParagraph($Line);
'type' => 'Paragraph',
'identified' => true, $CurrentBlock['identified'] = true;
'element' => array(
'name' => 'p',
'text' => $text,
'handler' => 'line',
),
);
} }
} }
$elements []= $CurrentBlock['element']; # ~
unset($elements[0]); if (isset($CurrentBlock['incomplete']) and method_exists($this, 'complete'.$CurrentBlock['type']))
{
$CurrentBlock = $this->{'complete'.$CurrentBlock['type']}($CurrentBlock);
}
# ~ # ~
$markup = $this->elements($elements); $Elements []= $CurrentBlock['element'];
unset($Elements[0]);
# ~
$markup = $this->elements($Elements);
# ~ # ~
@ -278,15 +291,22 @@ class Parsedown
} }
# #
# Rule # Code
protected function identifyRule($Line) protected function identifyCodeBlock($Line)
{ {
if (preg_match('/^(['.$Line['text'][0].'])([ ]{0,2}\1){2,}[ ]*$/', $Line['text'])) if ($Line['indent'] >= 4)
{ {
$text = substr($Line['body'], 4);
$Block = array( $Block = array(
'element' => array( 'element' => array(
'name' => 'hr' 'name' => 'pre',
'handler' => 'element',
'text' => array(
'name' => 'code',
'text' => $text,
),
), ),
); );
@ -294,107 +314,72 @@ class Parsedown
} }
} }
# protected function addToCodeBlock($Line, $Block)
# Reference
protected function identifyReference($Line)
{ {
if (preg_match('/^\[(.+?)\]:[ ]*<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches)) if ($Line['indent'] >= 4)
{ {
$label = strtolower($matches[1]); if (isset($Block['interrupted']))
$this->references[$label] = array(
'url' => $matches[2],
);
if (isset($matches[3]))
{ {
$this->references[$label]['title'] = $matches[3]; $Block['element']['text']['text'] .= "\n";
unset($Block['interrupted']);
} }
$Block = array( $Block['element']['text']['text'] .= "\n";
'element' => null,
); $text = substr($Line['body'], 4);
$Block['element']['text']['text'] .= $text;
return $Block; return $Block;
} }
} }
# protected function completeCodeBlock($Block)
# Setext
protected function identifySetext($Line, array $Block = null)
{ {
if ( ! isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted'])) $text = $Block['element']['text']['text'];
{
return;
}
if (chop($Line['text'], $Line['text'][0]) === '') $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
{
$Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2';
return $Block; $Block['element']['text']['text'] = $text;
}
return $Block;
} }
# #
# Markup # Comment
protected function identifyMarkup($Line) protected function identifyComment($Line)
{ {
if (preg_match('/^<(\w[\w\d]*)(?:[ ][^>\/]*)?(\/?)[ ]*>/', $Line['text'], $matches)) if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!')
{ {
if (in_array($matches[1], $this->textLevelElements))
{
return;
}
$Block = array( $Block = array(
'element' => $Line['body'], 'element' => $Line['body'],
); );
if ($matches[2] or $matches[1] === 'hr' or preg_match('/<\/'.$matches[1].'>[ ]*$/', $Line['text'])) if (preg_match('/-->$/', $Line['text']))
{ {
$Block['closed'] = true; $Block['closed'] = true;
} }
else
{
$Block['depth'] = 0;
$Block['start'] = '<'.$matches[1].'>';
$Block['end'] = '</'.$matches[1].'>';
}
return $Block; return $Block;
} }
} }
protected function addToMarkup($Line, array $Block) protected function addToComment($Line, array $Block)
{ {
if (isset($Block['closed'])) if (isset($Block['closed']))
{ {
return; return;
} }
if (stripos($Line['text'], $Block['start']) !== false) # opening tag $Block['element'] .= "\n" . $Line['body'];
{
$Block['depth'] ++;
}
if (stripos($Line['text'], $Block['end']) !== false) # closing tag if (preg_match('/-->$/', $Line['text']))
{ {
if ($Block['depth'] > 0) $Block['closed'] = true;
{
$Block['depth'] --;
}
else
{
$Block['closed'] = true;
}
} }
$Block['element'] .= "\n".$Line['body'];
return $Block; return $Block;
} }
@ -403,7 +388,7 @@ class Parsedown
protected function identifyFencedCode($Line) protected function identifyFencedCode($Line)
{ {
if (preg_match('/^(['.$Line['text'][0].']{3,})[ ]*(\w+)?[ ]*$/', $Line['text'], $matches)) if (preg_match('/^(['.$Line['text'][0].']{3,})[ ]*([\w-]+)?[ ]*$/', $Line['text'], $matches))
{ {
$Element = array( $Element = array(
'name' => 'code', 'name' => 'code',
@ -455,9 +440,18 @@ class Parsedown
return $Block; return $Block;
} }
$string = htmlspecialchars($Line['body'], ENT_NOQUOTES, 'UTF-8'); $Block['element']['text']['text'] .= "\n".$Line['body'];;
$Block['element']['text']['text'] .= "\n".$string;; return $Block;
}
protected function completeFencedCode($Block)
{
$text = $Block['element']['text']['text'];
$text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
$Block['element']['text']['text'] = $text;
return $Block; return $Block;
} }
@ -522,7 +516,7 @@ class Parsedown
if ( ! isset($Block['interrupted'])) if ( ! isset($Block['interrupted']))
{ {
$text = preg_replace('/^[ ]{0,2}/', '', $Line['body']); $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
$Block['li']['text'] []= $text; $Block['li']['text'] []= $text;
@ -533,7 +527,7 @@ class Parsedown
{ {
$Block['li']['text'] []= ''; $Block['li']['text'] []= '';
$text = preg_replace('/^[ ]{0,2}/', '', $Line['body']); $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
$Block['li']['text'] []= $text; $Block['li']['text'] []= $text;
@ -569,6 +563,8 @@ class Parsedown
if (isset($Block['interrupted'])) if (isset($Block['interrupted']))
{ {
$Block['element']['text'] []= ''; $Block['element']['text'] []= '';
unset($Block['interrupted']);
} }
$Block['element']['text'] []= $matches[1]; $Block['element']['text'] []= $matches[1];
@ -584,12 +580,106 @@ class Parsedown
} }
} }
#
# Rule
protected function identifyRule($Line)
{
if (preg_match('/^(['.$Line['text'][0].'])([ ]{0,2}\1){2,}[ ]*$/', $Line['text']))
{
$Block = array(
'element' => array(
'name' => 'hr'
),
);
return $Block;
}
}
#
# Setext
protected function identifySetext($Line, array $Block = null)
{
if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
{
return;
}
if (chop($Line['text'], $Line['text'][0]) === '')
{
$Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2';
return $Block;
}
}
#
# Markup
protected function identifyMarkup($Line)
{
if (preg_match('/^<(\w[\w\d]*)(?:[ ][^>\/]*)?(\/?)[ ]*>/', $Line['text'], $matches))
{
if (in_array($matches[1], $this->textLevelElements))
{
return;
}
$Block = array(
'element' => $Line['body'],
);
if ($matches[2] or $matches[1] === 'hr' or preg_match('/<\/'.$matches[1].'>[ ]*$/', $Line['text']))
{
$Block['closed'] = true;
}
else
{
$Block['depth'] = 0;
$Block['name'] = $matches[1];
}
return $Block;
}
}
protected function addToMarkup($Line, array $Block)
{
if (isset($Block['closed']))
{
return;
}
if (preg_match('/<'.$Block['name'].'([ ][^\/]+)?>/', $Line['text'])) # opening tag
{
$Block['depth'] ++;
}
if (stripos($Line['text'], '</'.$Block['name'].'>') !== false) # closing tag
{
if ($Block['depth'] > 0)
{
$Block['depth'] --;
}
else
{
$Block['closed'] = true;
}
}
$Block['element'] .= "\n".$Line['body'];
return $Block;
}
# #
# Table # Table
protected function identifyTable($Line, array $Block = null) protected function identifyTable($Line, array $Block = null)
{ {
if ( ! isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted'])) if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
{ {
return; return;
} }
@ -740,49 +830,26 @@ class Parsedown
} }
# #
# Code # Definitions
#
protected function identifyCodeBlock($Line) protected function identifyReference($Line)
{ {
if ($Line['indent'] >= 4) if (preg_match('/^\[(.+?)\]:[ ]*<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches))
{ {
$text = substr($Line['body'], 4); $Definition = array(
$text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8'); 'id' => strtolower($matches[1]),
'data' => array(
$Block = array( 'url' => $matches[2],
'element' => array(
'name' => 'pre',
'handler' => 'element',
'text' => array(
'name' => 'code',
'text' => $text,
),
), ),
); );
return $Block; if (isset($matches[3]))
}
}
protected function addToCodeBlock($Line, $Block)
{
if ($Line['indent'] >= 4)
{
if (isset($Block['interrupted']))
{ {
$Block['element']['text']['text'] .= "\n"; $Definition['data']['title'] = $matches[3];
unset($Block['interrupted']);
} }
$Block['element']['text']['text'] .= "\n"; return $Definition;
$text = substr($Line['body'], 4);
$text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
$Block['element']['text']['text'] .= $text;
return $Block;
} }
} }
@ -790,7 +857,24 @@ class Parsedown
# ~ # ~
# #
private function element(array $Element) protected function buildParagraph($Line)
{
$Block = array(
'element' => array(
'name' => 'p',
'text' => $Line['text'],
'handler' => 'line',
),
);
return $Block;
}
#
# ~
#
protected function element(array $Element)
{ {
$markup = '<'.$Element['name']; $markup = '<'.$Element['name'];
@ -825,7 +909,7 @@ class Parsedown
return $markup; return $markup;
} }
private function elements(array $Elements) protected function elements(array $Elements)
{ {
$markup = ''; $markup = '';
@ -838,7 +922,7 @@ class Parsedown
$markup .= "\n"; $markup .= "\n";
if (is_string($Element)) # because of markup if (is_string($Element)) # because of Markup
{ {
$markup .= $Element; $markup .= $Element;
@ -857,7 +941,7 @@ class Parsedown
# Spans # Spans
# #
protected $spanMarkers = array( protected $SpanTypes = array(
'!' => array('Link'), # ? '!' => array('Link'), # ?
'&' => array('Ampersand'), '&' => array('Ampersand'),
'*' => array('Emphasis'), '*' => array('Emphasis'),
@ -870,8 +954,14 @@ class Parsedown
'\\' => array('EscapeSequence'), '\\' => array('EscapeSequence'),
); );
# ~
protected $spanMarkerList = '*_!&[</`~\\'; protected $spanMarkerList = '*_!&[</`~\\';
#
# ~
#
public function line($text) public function line($text)
{ {
$markup = ''; $markup = '';
@ -880,51 +970,55 @@ class Parsedown
$markerPosition = 0; $markerPosition = 0;
while ($markedExcerpt = strpbrk($remainder, $this->spanMarkerList)) while ($excerpt = strpbrk($remainder, $this->spanMarkerList))
{ {
$marker = $markedExcerpt[0]; $marker = $excerpt[0];
$markerPosition += strpos($remainder, $marker); $markerPosition += strpos($remainder, $marker);
foreach ($this->spanMarkers[$marker] as $spanType) $Excerpt = array('text' => $excerpt, 'context' => $text);
foreach ($this->SpanTypes[$marker] as $spanType)
{ {
$handler = 'identify'.$spanType; $handler = 'identify'.$spanType;
$Span = $this->$handler($markedExcerpt, $text); $Span = $this->$handler($Excerpt);
if (isset($Span)) if ( ! isset($Span))
{ {
# The identified span can be ahead of the marker. continue;
if (isset($Span['position']) and $Span['position'] > $markerPosition)
{
continue;
}
# Spans that start at the position of their marker don't have to set a position.
if ( ! isset($Span['position']))
{
$Span['position'] = $markerPosition;
}
$unmarkedText = substr($text, 0, $Span['position']);
$markup .= $this->readPlainText($unmarkedText);
$markup .= isset($Span['element']) ? $this->element($Span['element']) : $Span['markup'];
$text = substr($text, $Span['position'] + $Span['extent']);
$remainder = $text;
$markerPosition = 0;
continue 2;
} }
# The identified span can be ahead of the marker.
if (isset($Span['position']) and $Span['position'] > $markerPosition)
{
continue;
}
# Spans that start at the position of their marker don't have to set a position.
if ( ! isset($Span['position']))
{
$Span['position'] = $markerPosition;
}
$plainText = substr($text, 0, $Span['position']);
$markup .= $this->readPlainText($plainText);
$markup .= isset($Span['markup']) ? $Span['markup'] : $this->element($Span['element']);
$text = substr($text, $Span['position'] + $Span['extent']);
$remainder = $text;
$markerPosition = 0;
continue 2;
} }
$remainder = substr($markedExcerpt, 1); $remainder = substr($excerpt, 1);
$markerPosition ++; $markerPosition ++;
} }
@ -938,14 +1032,14 @@ class Parsedown
# ~ # ~
# #
protected function identifyUrl($excerpt, $text) protected function identifyUrl($Excerpt)
{ {
if ( ! isset($excerpt[1]) or $excerpt[1] !== '/') if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '/')
{ {
return; return;
} }
if (preg_match('/\bhttps?:[\/]{2}[^\s]+\b\/*/ui', $text, $matches, PREG_OFFSET_CAPTURE)) if (preg_match('/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE))
{ {
$url = str_replace(array('&', '<'), array('&amp;', '&lt;'), $matches[0][0]); $url = str_replace(array('&', '<'), array('&amp;', '&lt;'), $matches[0][0]);
@ -963,9 +1057,9 @@ class Parsedown
} }
} }
protected function identifyAmpersand($excerpt) protected function identifyAmpersand($Excerpt)
{ {
if ( ! preg_match('/^&#?\w+;/', $excerpt)) if ( ! preg_match('/^&#?\w+;/', $Excerpt['text']))
{ {
return array( return array(
'markup' => '&amp;', 'markup' => '&amp;',
@ -974,14 +1068,14 @@ class Parsedown
} }
} }
protected function identifyStrikethrough($excerpt) protected function identifyStrikethrough($Excerpt)
{ {
if ( ! isset($excerpt[1])) if ( ! isset($Excerpt['text'][1]))
{ {
return; return;
} }
if ($excerpt[1] === $excerpt[0] and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $excerpt, $matches)) if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches))
{ {
return array( return array(
'extent' => strlen($matches[0]), 'extent' => strlen($matches[0]),
@ -994,12 +1088,12 @@ class Parsedown
} }
} }
protected function identifyEscapeSequence($excerpt) protected function identifyEscapeSequence($Excerpt)
{ {
if (in_array($excerpt[1], $this->specialCharacters)) if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters))
{ {
return array( return array(
'markup' => $excerpt[1], 'markup' => $Excerpt['text'][1],
'extent' => 2, 'extent' => 2,
); );
} }
@ -1013,9 +1107,9 @@ class Parsedown
); );
} }
protected function identifyUrlTag($excerpt) protected function identifyUrlTag($Excerpt)
{ {
if (strpos($excerpt, '>') !== false and preg_match('/^<(https?:[\/]{2}[^\s]+?)>/i', $excerpt, $matches)) if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(https?:[\/]{2}[^\s]+?)>/i', $Excerpt['text'], $matches))
{ {
$url = str_replace(array('&', '<'), array('&amp;', '&lt;'), $matches[1]); $url = str_replace(array('&', '<'), array('&amp;', '&lt;'), $matches[1]);
@ -1032,9 +1126,9 @@ class Parsedown
} }
} }
protected function identifyEmailTag($excerpt) protected function identifyEmailTag($Excerpt)
{ {
if (strpos($excerpt, '>') !== false and preg_match('/<(\S+?@\S+?)>/', $excerpt, $matches)) if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\S+?@\S+?)>/', $Excerpt['text'], $matches))
{ {
return array( return array(
'extent' => strlen($matches[0]), 'extent' => strlen($matches[0]),
@ -1049,9 +1143,9 @@ class Parsedown
} }
} }
protected function identifyTag($excerpt) protected function identifyTag($Excerpt)
{ {
if (strpos($excerpt, '>') !== false and preg_match('/^<\/?\w.*?>/', $excerpt, $matches)) if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<\/?\w.*?>/', $Excerpt['text'], $matches))
{ {
return array( return array(
'markup' => $matches[0], 'markup' => $matches[0],
@ -1060,11 +1154,11 @@ class Parsedown
} }
} }
protected function identifyInlineCode($excerpt) protected function identifyInlineCode($Excerpt)
{ {
$marker = $excerpt[0]; $marker = $Excerpt['text'][0];
if (preg_match('/^('.$marker.'+)[ ]*(.+?)[ ]*(?<!'.$marker.')\1(?!'.$marker.')/', $excerpt, $matches)) if (preg_match('/^('.$marker.'+)[ ]*(.+?)[ ]*(?<!'.$marker.')\1(?!'.$marker.')/', $Excerpt['text'], $matches))
{ {
$text = $matches[2]; $text = $matches[2];
$text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8'); $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
@ -1079,25 +1173,25 @@ class Parsedown
} }
} }
protected function identifyLink($excerpt) protected function identifyLink($Excerpt)
{ {
$extent = $excerpt[0] === '!' ? 1 : 0; $extent = $Excerpt['text'][0] === '!' ? 1 : 0;
if (strpos($excerpt, ']') and preg_match('/\[((?:[^][]|(?R))*)\]/', $excerpt, $matches)) if (strpos($Excerpt['text'], ']') and preg_match('/\[((?:[^][]|(?R))*)\]/', $Excerpt['text'], $matches))
{ {
$Link = array('text' => $matches[1], 'label' => strtolower($matches[1])); $Link = array('text' => $matches[1], 'label' => strtolower($matches[1]));
$extent += strlen($matches[0]); $extent += strlen($matches[0]);
$substring = substr($excerpt, $extent); $substring = substr($Excerpt['text'], $extent);
if (preg_match('/^\s*\[(.+?)\]/', $substring, $matches)) if (preg_match('/^\s*\[([^][]+)\]/', $substring, $matches))
{ {
$Link['label'] = strtolower($matches[1]); $Link['label'] = strtolower($matches[1]);
if (isset($this->references[$Link['label']])) if (isset($this->Definitions['Reference'][$Link['label']]))
{ {
$Link += $this->references[$Link['label']]; $Link += $this->Definitions['Reference'][$Link['label']];
$extent += strlen($matches[0]); $extent += strlen($matches[0]);
} }
@ -1106,9 +1200,9 @@ class Parsedown
return; return;
} }
} }
elseif ($this->references and isset($this->references[$Link['label']])) elseif (isset($this->Definitions['Reference'][$Link['label']]))
{ {
$Link += $this->references[$Link['label']]; $Link += $this->Definitions['Reference'][$Link['label']];
if (preg_match('/^[ ]*\[\]/', $substring, $matches)) if (preg_match('/^[ ]*\[\]/', $substring, $matches))
{ {
@ -1138,7 +1232,7 @@ class Parsedown
$url = str_replace(array('&', '<'), array('&amp;', '&lt;'), $Link['url']); $url = str_replace(array('&', '<'), array('&amp;', '&lt;'), $Link['url']);
if ($excerpt[0] === '!') if ($Excerpt['text'][0] === '!')
{ {
$Element = array( $Element = array(
'name' => 'img', 'name' => 'img',
@ -1171,20 +1265,20 @@ class Parsedown
); );
} }
protected function identifyEmphasis($excerpt) protected function identifyEmphasis($Excerpt)
{ {
if ( ! isset($excerpt[1])) if ( ! isset($Excerpt['text'][1]))
{ {
return; return;
} }
$marker = $excerpt[0]; $marker = $Excerpt['text'][0];
if ($excerpt[1] === $marker and preg_match($this->strongRegex[$marker], $excerpt, $matches)) if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches))
{ {
$emphasis = 'strong'; $emphasis = 'strong';
} }
elseif (preg_match($this->emRegex[$marker], $excerpt, $matches)) elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches))
{ {
$emphasis = 'em'; $emphasis = 'em';
} }
@ -1276,7 +1370,7 @@ class Parsedown
# Fields # Fields
# #
protected $references = array(); # » Definitions['reference'] protected $Definitions;
# #
# Read-only # Read-only
@ -1285,12 +1379,12 @@ class Parsedown
'\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!',
); );
protected $strongRegex = array( protected $StrongRegex = array(
'*' => '/^[*]{2}((?:[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s', '*' => '/^[*]{2}((?:[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s',
'_' => '/^__((?:[^_]|_[^_]*_)+?)__(?!_)/us', '_' => '/^__((?:[^_]|_[^_]*_)+?)__(?!_)/us',
); );
protected $emRegex = array( protected $EmRegex = array(
'*' => '/^[*]((?:[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s', '*' => '/^[*]((?:[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s',
'_' => '/^_((?:[^_]|__[^_]*__)+?)_(?!_)\b/us', '_' => '/^_((?:[^_]|__[^_]*__)+?)_(?!_)\b/us',
); );
@ -1298,12 +1392,12 @@ class Parsedown
protected $textLevelElements = array( protected $textLevelElements = array(
'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont', 'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont',
'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing', 'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing',
'i', 'rp', 'sub', 'code', 'strike', 'marquee', 'i', 'rp', 'del', 'code', 'strike', 'marquee',
'q', 'rt', 'sup', 'font', 'strong', 'q', 'rt', 'ins', 'font', 'strong',
's', 'tt', 'var', 'mark', 's', 'tt', 'sub', 'mark',
'u', 'xm', 'wbr', 'nobr', 'u', 'xm', 'sup', 'nobr',
'ruby', 'var', 'ruby',
'span', 'wbr', 'span',
'time', 'time',
); );
} }

View File

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

View File

@ -1,67 +0,0 @@
<?php
include 'Parsedown.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

@ -1,18 +0,0 @@
<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

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

View File

@ -1,21 +0,0 @@
<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

@ -1,4 +0,0 @@
| 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

@ -1,8 +0,0 @@
<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

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

View File

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

View File

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

View File

@ -1,5 +0,0 @@
<div>_content_</div>
<p>sparse:</p>
<div>
_content_
</div>

View File

@ -1,7 +0,0 @@
<div>_content_</div>
sparse:
<div>
_content_
</div>

View File

@ -1,8 +0,0 @@
<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

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

View File

@ -1,6 +0,0 @@
<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

@ -1,11 +0,0 @@
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

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

View File

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

View File

@ -1,2 +0,0 @@
<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

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

View File

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

View File

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

View File

@ -1,12 +0,0 @@
<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

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

View File

@ -1,8 +0,0 @@
<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

@ -1,15 +0,0 @@
___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

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

View File

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

View File

@ -1,8 +0,0 @@
<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

@ -1,13 +0,0 @@
_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

@ -1,4 +0,0 @@
<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

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

View File

@ -1,6 +0,0 @@
<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

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,28 +0,0 @@
<p>Headings:</p>
<h2 id="overview">Overview</h2>
<p>blah</p>
<H2 id="block">Block Elements</H2>
<p>blah</p>
<h3 id="span">
Span Elements
</h3>
<p>blah</p>
<p>Hr's:</p>
<hr>
<p>blah</p>
<hr/>
<p>blah</p>
<hr />
<p>blah</p>
<hr>
<p>blah</p>
<hr/>
<p>blah</p>
<hr />
<p>blah</p>
<hr class="foo" id="bar" />
<p>blah</p>
<hr class="foo" id="bar"/>
<p>blah</p>
<hr class="foo" id="bar" >
<p>blah</p>

View File

@ -1,39 +0,0 @@
Headings:
<h2 id="overview">Overview</h2>
blah
<H2 id="block">Block Elements</H2>
blah
<h3 id="span">
Span Elements
</h3>
blah
Hr's:
<hr>
blah
<hr/>
blah
<hr />
blah
<hr>
blah
<hr/>
blah
<hr />
blah
<hr class="foo" id="bar" />
blah
<hr class="foo" id="bar"/>
blah
<hr class="foo" id="bar" >
blah

View File

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

View File

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

View File

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

View File

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

View File

@ -1,3 +0,0 @@
<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" title="Example">explicit</a> reference link with a title</p>

View File

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

View File

@ -1,4 +0,0 @@
<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

@ -1,7 +0,0 @@
[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

@ -1 +0,0 @@
<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

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

View File

@ -1 +0,0 @@
<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

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

View File

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

View File

@ -1,2 +0,0 @@
> quote
the rest of it

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,13 +0,0 @@
<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

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

View File

@ -1,12 +0,0 @@
<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

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

View File

@ -1,2 +0,0 @@
<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

@ -1,6 +0,0 @@
[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

@ -1,4 +0,0 @@
<hr />
<p>attributes:</p>
<hr style="background: #9bd;" />
<p>...</p>

View File

@ -1,7 +0,0 @@
<hr />
attributes:
<hr style="background: #9bd;" />
...

View File

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

View File

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

View File

@ -1,11 +0,0 @@
<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

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

View File

@ -1,37 +0,0 @@
<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

@ -1,11 +0,0 @@
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

@ -1,4 +0,0 @@
<p>an <b>important</b> <a href=''>link</a></p>
<p>broken<br/>
line</p>
<p><b>inline tag</b> at the beginning</p>

View File

@ -1,6 +0,0 @@
an <b>important</b> <a href=''>link</a>
broken<br/>
line
<b>inline tag</b> at the beginning

View File

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

View File

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

View File

@ -1,15 +0,0 @@
<ul>
<li>
<p>li</p>
</li>
<li>li</li>
</ul>
<hr />
<ul>
<li>
<p>li</p>
<ul>
<li>indented li</li>
</ul>
</li>
</ul>

View File

@ -1,9 +0,0 @@
- li
- li
---
- li
- indented li

View File

@ -1,6 +0,0 @@
<p>AT&amp;T has an ampersand in their name</p>
<p>this &amp; that</p>
<p>4 &lt; 5 and 6 > 5</p>
<p><a href="http://example.com/autolink?a=1&amp;b=2">http://example.com/autolink?a=1&amp;b=2</a></p>
<p><a href="/script?a=1&amp;b=2">inline link</a></p>
<p><a href="http://example.com/?a=1&amp;b=2">reference link</a></p>

View File

@ -1,13 +0,0 @@
AT&T has an ampersand in their name
this & that
4 < 5 and 6 > 5
<http://example.com/autolink?a=1&b=2>
[inline link](/script?a=1&b=2)
[reference link][1]
[1]: http://example.com/?a=1&b=2

View File

@ -1,3 +0,0 @@
<p><del>strikethrough</del></p>
<p>here's <del>one</del> followed by <del>another one</del></p>
<p>~~ this ~~ is not one neither is ~this~</p>

View File

@ -1,5 +0,0 @@
~~strikethrough~~
here's ~~one~~ followed by ~~another one~~
~~ this ~~ is not one neither is ~this~

View File

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

View File

@ -1,11 +0,0 @@
*em **strong em***
***strong em** em*
*em **strong em** em*
_em __strong em___
___strong em__ em_
_em __strong em__ em_

View File

@ -1,6 +0,0 @@
<pre><code>&lt;?php
$message = 'Hello World!';
echo $message;
echo "following a blank line";</code></pre>

View File

@ -1,6 +0,0 @@
<?php
$message = 'Hello World!';
echo $message;
echo "following a blank line";

View File

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

View File

@ -1,4 +0,0 @@
| _header_ 1 | header 2 |
| ------------ | ------------ |
| _cell_ 1.1 | ~~cell~~ 1.2 |
| `cell` 2.1 | cell 2.2 |

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