mirror of https://github.com/erusev/parsedown.git
Merge 680287bb78
into 6598f3860c
This commit is contained in:
commit
899f74dc4f
|
@ -553,15 +553,23 @@ class Parsedown
|
|||
}
|
||||
|
||||
$text = trim($text, ' ');
|
||||
$link = preg_replace('/[^\p{L}\p{N}\p{M}-]+/u', '', mb_strtolower(mb_ereg_replace(' ','-',$text)));
|
||||
$attr = array();
|
||||
if (!empty($link)) {
|
||||
$attr = array(
|
||||
'id' => $link,
|
||||
);
|
||||
}
|
||||
|
||||
$Block = array(
|
||||
'element' => array(
|
||||
'name' => 'h' . $level,
|
||||
'attributes' => $attr,
|
||||
'handler' => array(
|
||||
'function' => 'lineElements',
|
||||
'argument' => $text,
|
||||
'destination' => 'elements',
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -1992,3 +2000,4 @@ class Parsedown
|
|||
'wbr', 'time',
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,8 +54,10 @@ class ParsedownTest extends TestCase
|
|||
$this->Parsedown->setStrictMode(substr($test, 0, 6) === 'strict');
|
||||
|
||||
$actualMarkup = $this->Parsedown->text($markdown);
|
||||
$actualMarkup = str_replace("\r\n", "\n", $actualMarkup);
|
||||
$actualMarkup = str_replace("\r", "\n", $actualMarkup);
|
||||
|
||||
$this->assertEquals($expectedMarkup, $actualMarkup);
|
||||
$this->assertEquals(trim($expectedMarkup), trim($actualMarkup));
|
||||
}
|
||||
|
||||
function testRawHtml()
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<h1>h1</h1>
|
||||
<h2>h2</h2>
|
||||
<h3>h3</h3>
|
||||
<h4>h4</h4>
|
||||
<h5>h5</h5>
|
||||
<h6>h6</h6>
|
||||
<p>####### not a heading</p>
|
||||
<h1>closed h1</h1>
|
||||
<h1></h1>
|
||||
<h2></h2>
|
||||
<h1># of levels</h1>
|
||||
<h1># of levels #</h1>
|
||||
<h1>heading</h1>
|
||||
<h1 id="h1">h1</h1>
|
||||
<h2 id="h2">h2</h2>
|
||||
<h3 id="h3">h3</h3>
|
||||
<h4 id="h4">h4</h4>
|
||||
<h5 id="h5">h5</h5>
|
||||
<h6 id="h6">h6</h6>
|
||||
<p>####### not a heading</p>
|
||||
<h1 id="closed-h1">closed h1</h1>
|
||||
<h1></h1>
|
||||
<h2></h2>
|
||||
<h1 id="#-of-levels"># of levels</h1>
|
||||
<h1 id="#-of-levels-#"># of levels #</h1>
|
||||
<h1 id="heading">heading</h1>
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<h1>h1</h1>
|
||||
<h2>h2</h2>
|
||||
<h3>h3</h3>
|
||||
<h4>h4</h4>
|
||||
<h5>h5</h5>
|
||||
<h6>h6</h6>
|
||||
<h1 id="h1">h1</h1>
|
||||
<h2 id="h2">h2</h2>
|
||||
<h3 id="h3">h3</h3>
|
||||
<h4 id="h4">h4</h4>
|
||||
<h5 id="h5">h5</h5>
|
||||
<h6 id="h6">h6</h6>
|
||||
<p>####### not a heading</p>
|
||||
<p>#not a heading</p>
|
||||
<h1>closed h1</h1>
|
||||
<h1 id="closed-h1">closed h1</h1>
|
||||
<h1></h1>
|
||||
<h2></h2>
|
||||
<h1># of levels</h1>
|
||||
<h1># of levels #</h1>
|
||||
<h1 id="#-of-levels"># of levels</h1>
|
||||
<h1 id="#-of-levels-#"># of levels #</h1>
|
||||
|
|
Loading…
Reference in New Issue