1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Compare commits

...

10 Commits
1.1.0 ... 1.1.2

Author SHA1 Message Date
9816507a75 markup should preserve empty lines 2014-11-19 20:18:56 +02:00
7000cbc2d2 improve readme 2014-11-12 22:27:29 +02:00
6df242bc97 improve readme 2014-11-12 03:37:36 +02:00
f4453fd729 improve readme 2014-11-12 03:36:17 +02:00
d8011c00ab improve readme 2014-11-09 13:40:39 +02:00
da5d75e97e resolve #209 2014-10-29 22:29:46 +02:00
2adb87ef41 Merge pull request #236 from naNuke/escapeComment
Ignore html comments as well with markupEscape option.
2014-10-10 21:11:23 +03:00
74926c9831 Add test of escaped html comment. 2014-10-10 20:07:41 +02:00
68f3aea036 Ignore html comments as well with markupEscape option. 2014-10-10 19:07:25 +02:00
f91e4dece3 improve consistency 2014-09-26 13:06:40 +03:00
7 changed files with 41 additions and 3 deletions

View File

@ -359,6 +359,11 @@ class Parsedown
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] === '!')
{
$Block = array(
@ -644,7 +649,7 @@ class Parsedown
'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;
}
@ -682,6 +687,13 @@ class Parsedown
}
}
if (isset($Block['interrupted']))
{
$Block['element'] .= "\n";
unset($Block['interrupted']);
}
$Block['element'] .= "\n".$Line['body'];
return $Block;
@ -1407,6 +1419,10 @@ class Parsedown
'_' => '/^_((?:[^_]|__[^_]*__)+?)_(?!_)\b/us',
);
protected $voidElements = array(
'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source',
);
protected $textLevelElements = array(
'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont',
'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing',

View File

@ -1,6 +1,6 @@
## Parsedown
Better [Markdown](http://en.wikipedia.org/wiki/Markdown) parser for PHP.
Better Markdown Parser in PHP
[[ 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)
* [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/)
* Extensible
* [Markdown Extra extension](https://github.com/erusev/parsedown-extra) <sup>new</sup>

View File

@ -109,6 +109,10 @@ paragraph
color: red;
}
</style>
comment
<!-- html comment -->
MARKDOWN_WITH_MARKUP;
$expectedHtml = <<<EXPECTED_HTML
@ -125,6 +129,8 @@ MARKDOWN_WITH_MARKUP;
color: red;
}</code></pre>
<p>&lt;/style></p>
<p>comment</p>
<p>&lt;!-- html comment --></p>
EXPECTED_HTML;
$parsedownWithNoMarkup = new Parsedown();
$parsedownWithNoMarkup->setMarkupEscaped(true);

View File

@ -0,0 +1,8 @@
<div>
line 1
line 2
line 3
line 4
</div>

8
test/data/sparse_html.md Normal file
View File

@ -0,0 +1,8 @@
<div>
line 1
line 2
line 3
line 4
</div>