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

Compare commits

...

2 Commits

Author SHA1 Message Date
2da10d277b resolve #105 2014-05-14 13:14:49 +03:00
532b5ede35 resolve #129 2014-05-14 01:11:05 +03:00
5 changed files with 63 additions and 7 deletions

View File

@ -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)
{

View File

@ -0,0 +1,5 @@
<!-- single line -->
<p>paragraph</p>
<!--
multiline -->
<p>paragraph</p>

View File

@ -0,0 +1,8 @@
<!-- single line -->
paragraph
<!--
multiline -->
paragraph

View File

@ -1,5 +1,8 @@
<div>_content_</div>
<p>sparse:</p>
<div>
<div class="inner">
_content_
</div>
</div>
</div>
<p>paragraph</p>

View File

@ -3,5 +3,9 @@
sparse:
<div>
<div class="inner">
_content_
</div>
</div>
</div>
paragraph