mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Compare commits
61 Commits
Author | SHA1 | Date | |
---|---|---|---|
f0fbdaa6ca | |||
e20c0a29bd | |||
712dd23d30 | |||
68f2871996 | |||
17e7e33847 | |||
7cb9646d98 | |||
325bdd9ff6 | |||
2a0700abda | |||
4e83d79d76 | |||
354842fd6e | |||
2b73e94c6c | |||
0182812d6c | |||
f5dd3455f9 | |||
1017f22cdd | |||
88854955d6 | |||
654dd74074 | |||
fee5b71998 | |||
149b687ee7 | |||
98b17e3354 | |||
da966b83f1 | |||
b9ab495cb4 | |||
408cb5c21f | |||
5dd0e8cb7b | |||
5521afde31 | |||
4317add3a2 | |||
47d8a1382b | |||
fd42f2e864 | |||
c0b7155572 | |||
be366b63ea | |||
68484504ca | |||
4fecd91f7d | |||
9dae844a6e | |||
df6fe915c6 | |||
576b0ea761 | |||
0f027dc04b | |||
179862bd6e | |||
019a4af2af | |||
51a08fad85 | |||
7fb08f334a | |||
85ad014f74 | |||
22336a1bcc | |||
f713e380ee | |||
5b01915a63 | |||
18d112a614 | |||
1b9641ad03 | |||
8baf537c12 | |||
05823567bc | |||
b7029ab176 | |||
102a947c7a | |||
7bb70186c1 | |||
3225c66863 | |||
d6dc5ba25b | |||
f5451a9eff | |||
849a89b121 | |||
28064a63b3 | |||
800aac5b56 | |||
b15d40e8a3 | |||
ddc5b7e2dd | |||
5a563008aa | |||
b6f795962f | |||
cdb2646063 |
@ -4,4 +4,5 @@ php:
|
|||||||
- 5.5
|
- 5.5
|
||||||
- 5.4
|
- 5.4
|
||||||
- 5.3
|
- 5.3
|
||||||
- 5.2
|
- 5.2
|
||||||
|
- hhvm
|
808
Parsedown.php
808
Parsedown.php
File diff suppressed because it is too large
Load Diff
20
README.md
20
README.md
@ -1,8 +1,20 @@
|
|||||||
## Parsedown
|
## Parsedown
|
||||||
|
|
||||||
Parsedown is a Markdown parser for PHP. It is fast, consistent and easy to use.
|
Better [Markdown](http://en.wikipedia.org/wiki/Markdown) parser for PHP.
|
||||||
|
|
||||||
[Home](http://parsedown.org) · [Demo](http://parsedown.org/explorer/) · [Tests](http://parsedown.org/tests/)
|
***
|
||||||
|
|
||||||
|
[ [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
|
### Installation
|
||||||
|
|
||||||
@ -11,9 +23,9 @@ Include `Parsedown.php` or install [the composer package](https://packagist.org/
|
|||||||
### Example
|
### Example
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$text = 'Hello **Parsedown**!';
|
$text = 'Hello *Parsedown*!';
|
||||||
|
|
||||||
$result = Parsedown::instance()->parse($text);
|
$result = Parsedown::instance()->parse($text);
|
||||||
|
|
||||||
echo $result; # prints: <p>Hello <strong>Parsedown</strong>!</p>
|
echo $result; # prints: <p>Hello <em>Parsedown</em>!</p>
|
||||||
```
|
```
|
||||||
|
@ -4,4 +4,5 @@
|
|||||||
<h4>h4</h4>
|
<h4>h4</h4>
|
||||||
<h5>h5</h5>
|
<h5>h5</h5>
|
||||||
<h6>h6</h6>
|
<h6>h6</h6>
|
||||||
<h1>closed h1</h1>
|
<h1>closed h1</h1>
|
||||||
|
<p>#</p>
|
@ -10,4 +10,6 @@
|
|||||||
|
|
||||||
###### h6
|
###### h6
|
||||||
|
|
||||||
# closed h1 #
|
# closed h1 #
|
||||||
|
|
||||||
|
#
|
@ -1,9 +1,5 @@
|
|||||||
<div>content</div>
|
<div>_content_</div>
|
||||||
<hr style="background: #eaa;" />
|
<p>sparse:</p>
|
||||||
<p>nested elements:</p>
|
|
||||||
<div>
|
<div>
|
||||||
parent
|
_content_
|
||||||
<div>
|
|
||||||
child
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
@ -1,12 +1,7 @@
|
|||||||
<div>content</div>
|
<div>_content_</div>
|
||||||
|
|
||||||
<hr style="background: #eaa;" />
|
sparse:
|
||||||
|
|
||||||
nested elements:
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
parent
|
_content_
|
||||||
<div>
|
|
||||||
child
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
2
tests/data/compound_emphasis.html
Normal file
2
tests/data/compound_emphasis.html
Normal 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>
|
4
tests/data/compound_emphasis.md
Normal file
4
tests/data/compound_emphasis.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
_`code`_ __`code`__
|
||||||
|
|
||||||
|
*`code`**`code`**`code`*
|
||||||
|
|
@ -1,5 +1,8 @@
|
|||||||
<p><strong><em>em strong</em></strong></p>
|
<p><strong><em>em strong</em></strong></p>
|
||||||
<p><strong><em>one</em> at the start</strong></p>
|
<p><strong><em>em strong</em> strong</strong></p>
|
||||||
<p><strong>one at the <em>end</em></strong></p>
|
<p><strong>strong <em>em strong</em></strong></p>
|
||||||
<p><strong>one <em>in the</em> middle</strong></p>
|
<p><strong>strong <em>em strong</em> strong</strong></p>
|
||||||
<p><strong>one with <em>asterisks</em></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>
|
@ -1,9 +1,15 @@
|
|||||||
___em strong___
|
___em strong___
|
||||||
|
|
||||||
___one_ at the start__
|
___em strong_ strong__
|
||||||
|
|
||||||
__one at the _end___
|
__strong _em strong___
|
||||||
|
|
||||||
__one _in the_ middle__
|
__strong _em strong_ strong__
|
||||||
|
|
||||||
**one with *asterisks***
|
***em strong***
|
||||||
|
|
||||||
|
***em strong* strong**
|
||||||
|
|
||||||
|
**strong *em strong***
|
||||||
|
|
||||||
|
**strong *em strong* strong**
|
1
tests/data/email.html
Normal file
1
tests/data/email.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<p>my email is <a href="mailto:me@example.com">me@example.com</a></p>
|
1
tests/data/email.md
Normal file
1
tests/data/email.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
my email is <me@example.com>
|
@ -1,5 +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><em>underscore</em>, <em>asterisk</em>, <em>one two</em>, <em>three four</em>, <em>a</em>, <em>b</em></p>
|
||||||
<p><em>multiline
|
<p><strong>strong</strong> and <em>em</em> and <strong>strong</strong> and <em>em</em></p>
|
||||||
emphasis</em></p>
|
<p><em>line
|
||||||
<p>_ this _ is not an emphasis, neither is _ this_, _this _, or _this*</p>
|
line
|
||||||
<p>an empty emphasis __ ** is not an emphasis</p>
|
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>
|
@ -1,8 +1,13 @@
|
|||||||
_underscore_, *asterisk*, _one two_, *three four*, _a_, *b*
|
_underscore_, *asterisk*, _one two_, *three four*, _a_, *b*
|
||||||
|
|
||||||
_multiline
|
**strong** and *em* and **strong** and *em*
|
||||||
emphasis_
|
|
||||||
|
|
||||||
_ this _ is not an emphasis, neither is _ this_, _this _, or _this*
|
_line
|
||||||
|
line
|
||||||
|
line_
|
||||||
|
|
||||||
an empty emphasis __ ** is not an emphasis
|
this_is_not_an_emphasis
|
||||||
|
|
||||||
|
an empty emphasis __ ** is not an emphasis
|
||||||
|
|
||||||
|
*mixed **double and* single asterisk** spans
|
@ -2,4 +2,5 @@
|
|||||||
|
|
||||||
$message = 'fenced code block';
|
$message = 'fenced code block';
|
||||||
echo $message;</code></pre>
|
echo $message;</code></pre>
|
||||||
<pre><code>tilde</code></pre>
|
<pre><code>tilde</code></pre>
|
||||||
|
<pre><code class="language-php">echo 'language identifier';</code></pre>
|
@ -7,4 +7,8 @@ echo $message;
|
|||||||
|
|
||||||
~~~
|
~~~
|
||||||
tilde
|
tilde
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
|
```php
|
||||||
|
echo 'language identifier';
|
||||||
|
```
|
1
tests/data/html_entity.html
Normal file
1
tests/data/html_entity.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<p>& © {</p>
|
1
tests/data/html_entity.md
Normal file
1
tests/data/html_entity.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
& © {
|
@ -1 +1 @@
|
|||||||
<p><img alt="Markdown Logo" src="/md.png"></p>
|
<p><img alt="Markdown Logo" src="/md.png" /></p>
|
@ -1,3 +1,3 @@
|
|||||||
![Markdown Logo][image]
|
![Markdown Logo][image]
|
||||||
|
|
||||||
[image]: /md.png
|
[image]: /md.png
|
||||||
|
1
tests/data/image_title.html
Normal file
1
tests/data/image_title.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<p><img alt="alt" src="/md.png" title="title" /></p>
|
1
tests/data/image_title.md
Normal file
1
tests/data/image_title.md
Normal file
@ -0,0 +1 @@
|
|||||||
|

|
@ -1,2 +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</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 with an empty link definition</p>
|
||||||
|
<p>an <a href="http://example.com" title="Example">explicit</a> reference link with a title</p>
|
@ -2,4 +2,8 @@ an [implicit] reference link
|
|||||||
|
|
||||||
[implicit]: http://example.com
|
[implicit]: http://example.com
|
||||||
|
|
||||||
an [implicit][] reference link with an empty link definition
|
an [implicit][] reference link with an empty link definition
|
||||||
|
|
||||||
|
an [explicit][example] reference link with a title
|
||||||
|
|
||||||
|
[example]: http://example.com "Example"
|
@ -1,2 +1,4 @@
|
|||||||
<p><a href="http://example.com">link</a></p>
|
<p><a href="http://example.com">link</a> and <a href="/tests/">another link</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"><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>
|
@ -1,3 +1,7 @@
|
|||||||
[link](http://example.com)
|
[link](http://example.com) and [another link](/tests/)
|
||||||
|
|
||||||
[](http://example.com)
|
[`link`](http://example.com)
|
||||||
|
|
||||||
|
[](http://example.com)
|
||||||
|
|
||||||
|
[ and text](http://example.com)
|
1
tests/data/inline_title.html
Normal file
1
tests/data/inline_title.html
Normal 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>
|
1
tests/data/inline_title.md
Normal file
1
tests/data/inline_title.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
[single quotes](http://example.com 'Example') and [double quotes](http://example.com "Example")
|
7
tests/data/multiline_list_paragraph.html
Normal file
7
tests/data/multiline_list_paragraph.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<p>li</p>
|
||||||
|
<p>line
|
||||||
|
line</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
4
tests/data/multiline_list_paragraph.md
Normal file
4
tests/data/multiline_list_paragraph.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
- li
|
||||||
|
|
||||||
|
line
|
||||||
|
line
|
10
tests/data/nested_block-level_html.html
Normal file
10
tests/data/nested_block-level_html.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<div>
|
||||||
|
_parent_
|
||||||
|
<div>
|
||||||
|
_child_
|
||||||
|
</div>
|
||||||
|
<pre>
|
||||||
|
_adopted child_
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
<p><em>outside</em></p>
|
11
tests/data/nested_block-level_html.md
Normal file
11
tests/data/nested_block-level_html.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<div>
|
||||||
|
_parent_
|
||||||
|
<div>
|
||||||
|
_child_
|
||||||
|
</div>
|
||||||
|
<pre>
|
||||||
|
_adopted child_
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
_outside_
|
12
tests/data/paragraph_list.html
Normal file
12
tests/data/paragraph_list.html
Normal 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>
|
9
tests/data/paragraph_list.md
Normal file
9
tests/data/paragraph_list.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
paragraph
|
||||||
|
- li
|
||||||
|
- li
|
||||||
|
|
||||||
|
paragraph
|
||||||
|
|
||||||
|
* li
|
||||||
|
|
||||||
|
* li
|
1
tests/data/reference_title.html
Normal file
1
tests/data/reference_title.html
Normal 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>
|
1
tests/data/reference_title.md
Normal file
1
tests/data/reference_title.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
[single quotes](http://example.com 'Title') and [double quotes](http://example.com "Title")
|
4
tests/data/self-closing_block-level_html.html
Normal file
4
tests/data/self-closing_block-level_html.html
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<hr />
|
||||||
|
<p>attributes:</p>
|
||||||
|
<hr style="background: #9bd;" />
|
||||||
|
<p>...</p>
|
7
tests/data/self-closing_block-level_html.md
Normal file
7
tests/data/self-closing_block-level_html.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<hr />
|
||||||
|
|
||||||
|
attributes:
|
||||||
|
|
||||||
|
<hr style="background: #9bd;" />
|
||||||
|
|
||||||
|
...
|
@ -1,3 +1,4 @@
|
|||||||
<p>an <b>important</b> <a href=''>link</a></p>
|
<p>an <b>important</b> <a href=''>link</a></p>
|
||||||
<p>broken<br/>
|
<p>broken<br/>
|
||||||
line</p>
|
line</p>
|
||||||
|
<p><b>inline tag</b> at the beginning</p>
|
@ -1,4 +1,6 @@
|
|||||||
an <b>important</b> <a href=''>link</a>
|
an <b>important</b> <a href=''>link</a>
|
||||||
|
|
||||||
broken<br/>
|
broken<br/>
|
||||||
line
|
line
|
||||||
|
|
||||||
|
<b>inline tag</b> at the beginning
|
@ -1,7 +1,6 @@
|
|||||||
<p>AT&T has an ampersand in their name</p>
|
<p>AT&T has an ampersand in their name</p>
|
||||||
<p>AT&T is another way to write it</p>
|
|
||||||
<p>this & that</p>
|
<p>this & that</p>
|
||||||
<p>4 < 5 and 6 > 5</p>
|
<p>4 < 5 and 6 > 5</p>
|
||||||
<p><a href="http://example.com/autolink?a=1&b=2">http://example.com/autolink?a=1&b=2</a> </p>
|
<p><a href="http://example.com/autolink?a=1&b=2">http://example.com/autolink?a=1&b=2</a></p>
|
||||||
<p><a href="/script?a=1&b=2">inline link</a></p>
|
<p><a href="/script?a=1&b=2">inline link</a></p>
|
||||||
<p><a href="http://example.com/?a=1&b=2">reference link</a></p>
|
<p><a href="http://example.com/?a=1&b=2">reference link</a></p>
|
@ -1,12 +1,10 @@
|
|||||||
AT&T has an ampersand in their name
|
AT&T has an ampersand in their name
|
||||||
|
|
||||||
AT&T is another way to write it
|
|
||||||
|
|
||||||
this & that
|
this & that
|
||||||
|
|
||||||
4 < 5 and 6 > 5
|
4 < 5 and 6 > 5
|
||||||
|
|
||||||
<http://example.com/autolink?a=1&b=2>
|
<http://example.com/autolink?a=1&b=2>
|
||||||
|
|
||||||
[inline link](/script?a=1&b=2)
|
[inline link](/script?a=1&b=2)
|
||||||
|
|
||||||
|
3
tests/data/strikethrough.html
Normal file
3
tests/data/strikethrough.html
Normal file
@ -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>
|
5
tests/data/strikethrough.md
Normal file
5
tests/data/strikethrough.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
~~strikethrough~~
|
||||||
|
|
||||||
|
here's ~~one~~ followed by ~~another one~~
|
||||||
|
|
||||||
|
~~ this ~~ is not one neither is ~this~
|
6
tests/data/strong_em.html
Normal file
6
tests/data/strong_em.html
Normal file
@ -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>
|
11
tests/data/strong_em.md
Normal file
11
tests/data/strong_em.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
*em **strong em***
|
||||||
|
|
||||||
|
***strong em** em*
|
||||||
|
|
||||||
|
*em **strong em** em*
|
||||||
|
|
||||||
|
_em __strong em___
|
||||||
|
|
||||||
|
___strong em__ em_
|
||||||
|
|
||||||
|
_em __strong em__ em_
|
6
tests/data/tab-indented_code_block.html
Normal file
6
tests/data/tab-indented_code_block.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<pre><code><?php
|
||||||
|
|
||||||
|
$message = 'Hello World!';
|
||||||
|
echo $message;
|
||||||
|
|
||||||
|
echo "following a blank line";</code></pre>
|
6
tests/data/tab-indented_code_block.md
Normal file
6
tests/data/tab-indented_code_block.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$message = 'Hello World!';
|
||||||
|
echo $message;
|
||||||
|
|
||||||
|
echo "following a blank line";
|
@ -3,4 +3,5 @@
|
|||||||
<p>[one][404] with no definition</p>
|
<p>[one][404] with no definition</p>
|
||||||
<p><a href="http://example.com">multiline
|
<p><a href="http://example.com">multiline
|
||||||
one</a> defined on 2 lines</p>
|
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">one</a> with an upper case label</p>
|
||||||
|
<p><a href="http://example.com"><code>link</code></a></p>
|
@ -13,4 +13,6 @@ one][website] defined on 2 lines
|
|||||||
|
|
||||||
[one][label] with an upper case label
|
[one][label] with an upper case label
|
||||||
|
|
||||||
[LABEL]: http://example.com
|
[LABEL]: http://example.com
|
||||||
|
|
||||||
|
[`link`][website]
|
2
tests/data/url_autolinking.html
Normal file
2
tests/data/url_autolinking.html
Normal file
@ -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>
|
3
tests/data/url_autolinking.md
Normal file
3
tests/data/url_autolinking.md
Normal file
@ -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)
|
Reference in New Issue
Block a user