mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Merge pull request #110 from wkpark/hr_heading
support HTML hr and headings
This commit is contained in:
commit
d0784d1006
@ -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;
|
||||||
}
|
}
|
||||||
|
28
tests/data/html_simple.html
Normal file
28
tests/data/html_simple.html
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<p>Headings:</p>
|
||||||
|
<h2 id="overview">Overview</h2>
|
||||||
|
<p>blah</p>
|
||||||
|
<H2 id="block">Block Elements</H2>
|
||||||
|
<p>blah</p>
|
||||||
|
<h3 id="span">
|
||||||
|
Span Elements
|
||||||
|
</h3>
|
||||||
|
<p>blah</p>
|
||||||
|
<p>Hr's:</p>
|
||||||
|
<hr>
|
||||||
|
<p>blah</p>
|
||||||
|
<hr/>
|
||||||
|
<p>blah</p>
|
||||||
|
<hr />
|
||||||
|
<p>blah</p>
|
||||||
|
<hr>
|
||||||
|
<p>blah</p>
|
||||||
|
<hr/>
|
||||||
|
<p>blah</p>
|
||||||
|
<hr />
|
||||||
|
<p>blah</p>
|
||||||
|
<hr class="foo" id="bar" />
|
||||||
|
<p>blah</p>
|
||||||
|
<hr class="foo" id="bar"/>
|
||||||
|
<p>blah</p>
|
||||||
|
<hr class="foo" id="bar" >
|
||||||
|
<p>blah</p>
|
39
tests/data/html_simple.md
Normal file
39
tests/data/html_simple.md
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
Headings:
|
||||||
|
|
||||||
|
<h2 id="overview">Overview</h2>
|
||||||
|
blah
|
||||||
|
<H2 id="block">Block Elements</H2>
|
||||||
|
blah
|
||||||
|
<h3 id="span">
|
||||||
|
Span Elements
|
||||||
|
</h3>
|
||||||
|
blah
|
||||||
|
|
||||||
|
Hr's:
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
blah
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
blah
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
blah
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
blah
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
blah
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
blah
|
||||||
|
|
||||||
|
<hr class="foo" id="bar" />
|
||||||
|
blah
|
||||||
|
|
||||||
|
<hr class="foo" id="bar"/>
|
||||||
|
blah
|
||||||
|
|
||||||
|
<hr class="foo" id="bar" >
|
||||||
|
blah
|
Loading…
x
Reference in New Issue
Block a user