mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
609ad47c38 | |||
7d7e89f5c3 | |||
5aad1d42d2 | |||
3ff5c623f2 | |||
637b516694 | |||
31b811d3fe |
@ -1 +0,0 @@
|
||||
src_dir: .
|
13
.travis.yml
13
.travis.yml
@ -1,15 +1,6 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.5
|
||||
- 5.4
|
||||
- 5.3
|
||||
|
||||
before_script:
|
||||
- composer require satooshi/php-coveralls:dev-master
|
||||
- mkdir -p build/logs
|
||||
|
||||
script:
|
||||
- phpunit --coverage-clover build/logs/clover.xml
|
||||
|
||||
after_script:
|
||||
- php vendor/bin/coveralls
|
||||
- 5.3
|
35
LICENSE.txt
35
LICENSE.txt
@ -1,21 +1,20 @@
|
||||
Copyright 2013 Emanuil Rusev
|
||||
http://erusev.com
|
||||
The MIT License (MIT)
|
||||
|
||||
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:
|
||||
Copyright (c) 2013 Emanuil Rusev, erusev.com
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
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 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.
|
||||
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.
|
@ -157,7 +157,6 @@ class Parsedown
|
||||
{
|
||||
$markup .= '<'.$list_type.'>'."\n";
|
||||
|
||||
# Of the same type and indentation.
|
||||
$list_items = preg_split('/^([ ]{'.$list_indentation.'})'.$list_marker_pattern.'[ ]/m', $list, -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
foreach ($list_items as $list_item)
|
||||
@ -175,7 +174,7 @@ class Parsedown
|
||||
}
|
||||
else
|
||||
{
|
||||
$list_item = $this->parse_lines($list_item);
|
||||
$list_item = $this->parse_lines($list_item, TRUE);
|
||||
}
|
||||
|
||||
$markup .= "\n".$list_item;
|
||||
@ -277,7 +276,7 @@ class Parsedown
|
||||
{
|
||||
if (strpos($block, "\n"))
|
||||
{
|
||||
$markup .= $this->parse_lines($block);
|
||||
$markup .= $this->parse_lines($block, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -292,7 +291,7 @@ class Parsedown
|
||||
return $markup;
|
||||
}
|
||||
|
||||
private function parse_lines($text)
|
||||
private function parse_lines($text, $paragraph_based = FALSE)
|
||||
{
|
||||
$text = trim($text, "\n");
|
||||
|
||||
@ -473,9 +472,11 @@ class Parsedown
|
||||
{
|
||||
if (isset($paragraph))
|
||||
{
|
||||
$element_text = $this->parse_inline_elements($paragraph);
|
||||
$paragraph_text = $this->parse_inline_elements($paragraph);
|
||||
|
||||
$markup .= '<p>'.$element_text.'</p>'."\n";
|
||||
$markup .= $markup === '' && $paragraph_based === FALSE
|
||||
? $paragraph_text
|
||||
: '<p>'.$paragraph_text.'</p>'."\n";
|
||||
|
||||
unset($paragraph);
|
||||
}
|
||||
@ -558,19 +559,19 @@ class Parsedown
|
||||
|
||||
# Inline Link / Image
|
||||
|
||||
if (strpos($text, '](') !== FALSE and preg_match_all('/(!?)\[(.*?)\]\((.*?)\)/', $text, $matches, PREG_SET_ORDER)) # inline
|
||||
if (strpos($text, '](') !== FALSE and preg_match_all('/(!?)(\[((?:[^][]+|(?2))*)\])\((.*?)\)/', $text, $matches, PREG_SET_ORDER)) # inline
|
||||
{
|
||||
foreach ($matches as $matches)
|
||||
{
|
||||
if ($matches[1]) # image
|
||||
{
|
||||
$element = '<img alt="'.$matches[2].'" src="'.$matches[3].'">';
|
||||
$element = '<img alt="'.$matches[3].'" src="'.$matches[4].'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
$element_text = $this->parse_inline_elements($matches[2]);
|
||||
$element_text = $this->parse_inline_elements($matches[3]);
|
||||
|
||||
$element = '<a href="'.$matches[3].'">'.$element_text.'</a>';
|
||||
$element = '<a href="'.$matches[4].'">'.$element_text.'</a>';
|
||||
}
|
||||
|
||||
$element_text = $this->parse_inline_elements($matches[1]);
|
||||
|
@ -14,4 +14,11 @@
|
||||
- another list item</code></pre>
|
||||
<p>Here's one with no space after markers:</p>
|
||||
<p>-list item
|
||||
-another list item</p>
|
||||
-another list item</p>
|
||||
<p>Here's one where items contain line breaks:</p>
|
||||
<ul>
|
||||
<li>list
|
||||
item</li>
|
||||
<li>another
|
||||
list item</li>
|
||||
</ul>
|
@ -17,4 +17,11 @@ Here's one with too much space before items:
|
||||
Here's one with no space after markers:
|
||||
|
||||
-list item
|
||||
-another list item
|
||||
-another list item
|
||||
|
||||
Here's one where items contain line breaks:
|
||||
|
||||
- list
|
||||
item
|
||||
- another
|
||||
list item
|
@ -0,0 +1,2 @@
|
||||
<p>Here's a <a href="http://parsedown.org">link</a>.</p>
|
||||
<p>Here's an image link: <a href="http://daringfireball.net/projects/markdown/"><img alt="MD Logo" src="http://parsedown.org/md.png"></a>.</p>
|
@ -0,0 +1,3 @@
|
||||
Here's a [link](http://parsedown.org).
|
||||
|
||||
Here's an image link: [](http://daringfireball.net/projects/markdown/).
|
Reference in New Issue
Block a user