added parsedown 0.9.0

main
Philip Häusler 11 years ago
parent 82c0d2acc2
commit 893bb5a9cf

@ -0,0 +1,3 @@
.DS_Store
.idea
nbproject

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

@ -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.

File diff suppressed because it is too large Load Diff

@ -0,0 +1,31 @@
## Parsedown
Better [Markdown](http://en.wikipedia.org/wiki/Markdown) parser for PHP.
***
[ [demo](http://parsedown.org/demo) ] [ [tests](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 and [hhvm](http://www.hhvm.com/)
* friendly to international input
### Installation
Include `Parsedown.php` or install [the composer package](https://packagist.org/packages/erusev/parsedown).
### Example
```php
$text = 'Hello *Parsedown*!';
$result = Parsedown::instance()->parse($text);
echo $result; # prints: <p>Hello <em>Parsedown</em>!</p>
```

@ -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": ""}
}
}

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

@ -0,0 +1,55 @@
<?php
include 'Parsedown.php';
class Test extends PHPUnit_Framework_TestCase
{
const provider_dir = 'data/';
/**
* @dataProvider provider
*/
function test_($markdown, $expected_markup)
{
$actual_markup = Parsedown::instance()->parse($markdown);
$this->assertEquals($expected_markup, $actual_markup);
}
function provider()
{
$provider = array();
$path = dirname(__FILE__).'/';
$DirectoryIterator = new DirectoryIterator($path . '/' . self::provider_dir);
foreach ($DirectoryIterator as $Item)
{
if ($Item->isFile())
{
$filename = $Item->getFilename();
$extension = pathinfo($filename, PATHINFO_EXTENSION);
if ($extension !== 'md')
continue;
$basename = $Item->getBasename('.md');
$markdown = file_get_contents($path . '/' . self::provider_dir . $basename . '.md');
if (!$markdown)
continue;
$expected_markup = file_get_contents($path . '/' . self::provider_dir . $basename . '.html');
$expected_markup = str_replace("\r\n", "\n", $expected_markup);
$expected_markup = str_replace("\r", "\n", $expected_markup);
$provider [] = array($markdown, $expected_markup);
}
}
return $provider;
}
}

@ -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>

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

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

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

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

@ -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>

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

@ -0,0 +1 @@
<p>a <code>code span</code></p>

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

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

@ -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>

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

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

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

@ -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>

@ -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**

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

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

@ -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>

@ -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

@ -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>

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

@ -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>

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

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

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

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

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

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

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

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

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

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

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

@ -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>

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

@ -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>

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

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

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

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

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

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

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

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

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

@ -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>

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

@ -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>

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

@ -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>

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

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

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

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

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

@ -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>

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -0,0 +1,7 @@
<p><a href="http://example.com">reference link</a></p>
<p><a href="http://example.com">one</a> with a semantic name</p>
<p>[one][404] with no definition</p>
<p><a href="http://example.com">multiline
one</a> defined on 2 lines</p>
<p><a href="http://example.com">one</a> with an upper case label</p>
<p><a href="http://example.com"><code>link</code></a></p>

@ -0,0 +1,18 @@
[reference link][1]
[1]: http://example.com
[one][website] with a semantic name
[website]: http://example.com
[one][404] with no definition
[multiline
one][website] defined on 2 lines
[one][label] with an upper case label
[LABEL]: http://example.com
[`link`][website]

@ -0,0 +1,10 @@
<ul>
<li>li</li>
<li>li</li>
</ul>
<p>mixed markers:</p>
<ul>
<li>li</li>
<li>li</li>
<li>li</li>
</ul>

@ -0,0 +1,8 @@
- li
- li
mixed markers:
* li
+ li
- li

@ -0,0 +1,2 @@
<p>an autolink <a href="http://example.com">http://example.com</a></p>
<p>inside of brackets [<a href="http://example.com">http://example.com</a>], inside of braces {<a href="http://example.com">http://example.com</a>}, inside of parentheses (<a href="http://example.com">http://example.com</a>)</p>

@ -0,0 +1,3 @@
an autolink http://example.com
inside of brackets [http://example.com], inside of braces {http://example.com}, inside of parentheses (http://example.com)

@ -0,0 +1 @@
<pre><code>code</code></pre>
Loading…
Cancel
Save