mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Compare commits
2 Commits
1.0.0-rc.5
...
1.0.0
Author | SHA1 | Date | |
---|---|---|---|
2da10d277b | |||
532b5ede35 |
@ -87,7 +87,7 @@ class Parsedown
|
||||
'8' => array('List'),
|
||||
'9' => array('List'),
|
||||
':' => array('Table'),
|
||||
'<' => array('Markup'),
|
||||
'<' => array('Comment', 'Markup'),
|
||||
'=' => array('Setext'),
|
||||
'>' => array('Quote'),
|
||||
'_' => array('Rule'),
|
||||
@ -346,6 +346,43 @@ class Parsedown
|
||||
return $Block;
|
||||
}
|
||||
|
||||
#
|
||||
# Comment
|
||||
|
||||
protected function identifyComment($Line)
|
||||
{
|
||||
if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!')
|
||||
{
|
||||
$Block = array(
|
||||
'element' => $Line['body'],
|
||||
);
|
||||
|
||||
if (preg_match('/-->$/', $Line['text']))
|
||||
{
|
||||
$Block['closed'] = true;
|
||||
}
|
||||
|
||||
return $Block;
|
||||
}
|
||||
}
|
||||
|
||||
protected function addToComment($Line, array $Block)
|
||||
{
|
||||
if (isset($Block['closed']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$Block['element'] .= "\n" . $Line['body'];
|
||||
|
||||
if (preg_match('/-->$/', $Line['text']))
|
||||
{
|
||||
$Block['closed'] = true;
|
||||
}
|
||||
|
||||
return $Block;
|
||||
}
|
||||
|
||||
#
|
||||
# Fenced Code
|
||||
|
||||
@ -601,8 +638,7 @@ class Parsedown
|
||||
else
|
||||
{
|
||||
$Block['depth'] = 0;
|
||||
$Block['start'] = '<'.$matches[1].'>';
|
||||
$Block['end'] = '</'.$matches[1].'>';
|
||||
$Block['name'] = $matches[1];
|
||||
}
|
||||
|
||||
return $Block;
|
||||
@ -616,12 +652,12 @@ class Parsedown
|
||||
return;
|
||||
}
|
||||
|
||||
if (stripos($Line['text'], $Block['start']) !== false) # opening tag
|
||||
if (preg_match('/<'.$Block['name'].'([ ][^\/]+)?>/', $Line['text'])) # opening tag
|
||||
{
|
||||
$Block['depth'] ++;
|
||||
}
|
||||
|
||||
if (stripos($Line['text'], $Block['end']) !== false) # closing tag
|
||||
if (stripos($Line['text'], '</'.$Block['name'].'>') !== false) # closing tag
|
||||
{
|
||||
if ($Block['depth'] > 0)
|
||||
{
|
||||
|
5
test/data/HTML_Comment.html
Normal file
5
test/data/HTML_Comment.html
Normal file
@ -0,0 +1,5 @@
|
||||
<!-- single line -->
|
||||
<p>paragraph</p>
|
||||
<!--
|
||||
multiline -->
|
||||
<p>paragraph</p>
|
8
test/data/HTML_Comment.md
Normal file
8
test/data/HTML_Comment.md
Normal file
@ -0,0 +1,8 @@
|
||||
<!-- single line -->
|
||||
|
||||
paragraph
|
||||
|
||||
<!--
|
||||
multiline -->
|
||||
|
||||
paragraph
|
@ -1,5 +1,8 @@
|
||||
<div>_content_</div>
|
||||
<p>sparse:</p>
|
||||
<div>
|
||||
<div class="inner">
|
||||
_content_
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>paragraph</p>
|
@ -3,5 +3,9 @@
|
||||
sparse:
|
||||
|
||||
<div>
|
||||
<div class="inner">
|
||||
_content_
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
paragraph
|
Reference in New Issue
Block a user