mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
9816507a75 | |||
7000cbc2d2 | |||
6df242bc97 | |||
f4453fd729 | |||
d8011c00ab | |||
da5d75e97e | |||
2adb87ef41 | |||
74926c9831 | |||
68f3aea036 | |||
f91e4dece3 |
@ -359,6 +359,11 @@ class Parsedown
|
|||||||
|
|
||||||
protected function identifyComment($Line)
|
protected function identifyComment($Line)
|
||||||
{
|
{
|
||||||
|
if ($this->markupEscaped)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!')
|
if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!')
|
||||||
{
|
{
|
||||||
$Block = array(
|
$Block = array(
|
||||||
@ -644,7 +649,7 @@ class Parsedown
|
|||||||
'element' => $Line['body'],
|
'element' => $Line['body'],
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($matches[2] or $matches[1] === 'hr' or preg_match('/<\/'.$matches[1].'>[ ]*$/', $Line['text']))
|
if ($matches[2] or in_array($matches[1], $this->voidElements) or preg_match('/<\/'.$matches[1].'>[ ]*$/', $Line['text']))
|
||||||
{
|
{
|
||||||
$Block['closed'] = true;
|
$Block['closed'] = true;
|
||||||
}
|
}
|
||||||
@ -682,6 +687,13 @@ class Parsedown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($Block['interrupted']))
|
||||||
|
{
|
||||||
|
$Block['element'] .= "\n";
|
||||||
|
|
||||||
|
unset($Block['interrupted']);
|
||||||
|
}
|
||||||
|
|
||||||
$Block['element'] .= "\n".$Line['body'];
|
$Block['element'] .= "\n".$Line['body'];
|
||||||
|
|
||||||
return $Block;
|
return $Block;
|
||||||
@ -1407,6 +1419,10 @@ class Parsedown
|
|||||||
'_' => '/^_((?:[^_]|__[^_]*__)+?)_(?!_)\b/us',
|
'_' => '/^_((?:[^_]|__[^_]*__)+?)_(?!_)\b/us',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
protected $voidElements = array(
|
||||||
|
'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source',
|
||||||
|
);
|
||||||
|
|
||||||
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',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
## Parsedown
|
## Parsedown
|
||||||
|
|
||||||
Better [Markdown](http://en.wikipedia.org/wiki/Markdown) parser for PHP.
|
Better Markdown Parser in PHP
|
||||||
|
|
||||||
[[ demo ]](http://parsedown.org/demo)
|
[[ demo ]](http://parsedown.org/demo)
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ Better [Markdown](http://en.wikipedia.org/wiki/Markdown) parser for PHP.
|
|||||||
|
|
||||||
* [Fast](http://parsedown.org/speed)
|
* [Fast](http://parsedown.org/speed)
|
||||||
* [Consistent](http://parsedown.org/consistency)
|
* [Consistent](http://parsedown.org/consistency)
|
||||||
* [GitHub Flavored](https://help.github.com/articles/github-flavored-markdown)
|
* [GitHub flavored](https://help.github.com/articles/github-flavored-markdown)
|
||||||
* [Tested](http://parsedown.org/tests/) in PHP 5.2, 5.3, 5.4, 5.5, 5.6 and [hhvm](http://www.hhvm.com/)
|
* [Tested](http://parsedown.org/tests/) in PHP 5.2, 5.3, 5.4, 5.5, 5.6 and [hhvm](http://www.hhvm.com/)
|
||||||
* Extensible
|
* Extensible
|
||||||
* [Markdown Extra extension](https://github.com/erusev/parsedown-extra) <sup>new</sup>
|
* [Markdown Extra extension](https://github.com/erusev/parsedown-extra) <sup>new</sup>
|
||||||
|
@ -109,6 +109,10 @@ paragraph
|
|||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
comment
|
||||||
|
|
||||||
|
<!-- html comment -->
|
||||||
MARKDOWN_WITH_MARKUP;
|
MARKDOWN_WITH_MARKUP;
|
||||||
|
|
||||||
$expectedHtml = <<<EXPECTED_HTML
|
$expectedHtml = <<<EXPECTED_HTML
|
||||||
@ -125,6 +129,8 @@ MARKDOWN_WITH_MARKUP;
|
|||||||
color: red;
|
color: red;
|
||||||
}</code></pre>
|
}</code></pre>
|
||||||
<p></style></p>
|
<p></style></p>
|
||||||
|
<p>comment</p>
|
||||||
|
<p><!-- html comment --></p>
|
||||||
EXPECTED_HTML;
|
EXPECTED_HTML;
|
||||||
$parsedownWithNoMarkup = new Parsedown();
|
$parsedownWithNoMarkup = new Parsedown();
|
||||||
$parsedownWithNoMarkup->setMarkupEscaped(true);
|
$parsedownWithNoMarkup->setMarkupEscaped(true);
|
||||||
|
8
test/data/sparse_html.html
Normal file
8
test/data/sparse_html.html
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<div>
|
||||||
|
line 1
|
||||||
|
|
||||||
|
line 2
|
||||||
|
line 3
|
||||||
|
|
||||||
|
line 4
|
||||||
|
</div>
|
8
test/data/sparse_html.md
Normal file
8
test/data/sparse_html.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<div>
|
||||||
|
line 1
|
||||||
|
|
||||||
|
line 2
|
||||||
|
line 3
|
||||||
|
|
||||||
|
line 4
|
||||||
|
</div>
|
Reference in New Issue
Block a user