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

support HR and headings as block markups

This commit is contained in:
Won-Kyu Park 2014-02-17 23:20:06 +09:00
parent bc30ad8e30
commit ccbdfabaff

View File

@ -130,12 +130,12 @@ class Parsedown
if ( ! isset($block['closed'])) if ( ! isset($block['closed']))
{ {
if (strpos($line, $block['start']) !== false) # opening tag if (stripos($line, $block['start']) !== false) # opening tag
{ {
$block['depth']++; $block['depth']++;
} }
if (strpos($line, $block['end']) !== false) # closing tag if (stripos($line, $block['end']) !== false) # closing tag
{ {
if ($block['depth'] > 0) if ($block['depth'] > 0)
{ {
@ -359,8 +359,15 @@ class Parsedown
{ {
$name = $substring; $name = $substring;
} }
$name = strtolower($name);
if ( ! ctype_alpha($name)) // hr,h1,h2,h3,h4,h5,h6 cases
if ($name[0] == 'h' and strpos('r123456', $name[1]) !== false)
{
if ($name == 'hr')
$is_self_closing = 1;
}
elseif ( ! ctype_alpha($name))
{ {
break; break;
} }
@ -392,7 +399,7 @@ class Parsedown
'depth' => 0, 'depth' => 0,
); );
if (strpos($outdented_line, $block['end'])) if (stripos($outdented_line, $block['end']))
{ {
$block['closed'] = true; $block['closed'] = true;
} }