mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
add headerOffset
This commit is contained in:
parent
819c68899d
commit
a4c297afc9
@ -101,6 +101,15 @@ class Parsedown
|
||||
|
||||
protected $strictMode;
|
||||
|
||||
function setHeaderOffset($headerOffset)
|
||||
{
|
||||
$this->headerOffset = $headerOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected $headerOffset = 0;
|
||||
|
||||
protected $safeLinksWhitelist = array(
|
||||
'http://',
|
||||
'https://',
|
||||
@ -542,7 +551,7 @@ class Parsedown
|
||||
|
||||
$Block = array(
|
||||
'element' => array(
|
||||
'name' => 'h' . $level,
|
||||
'name' => 'h' . min(6, $level + $this->headerOffset),
|
||||
'handler' => array(
|
||||
'function' => 'lineElements',
|
||||
'argument' => $text,
|
||||
|
@ -196,4 +196,16 @@ EXPECTED_HTML;
|
||||
$sameInstanceAgain = TestParsedown::instance('test late static binding');
|
||||
$this->assertSame($testParsedown, $sameInstanceAgain);
|
||||
}
|
||||
|
||||
function testHeaderOffset()
|
||||
{
|
||||
$markdown = '## header 2';
|
||||
$expectedMarkup = '<h4>header 2</h4>';
|
||||
|
||||
$this->Parsedown->setHeaderOffset(2);
|
||||
|
||||
$actualMarkup = $this->Parsedown->text($markdown);
|
||||
|
||||
$this->assertEquals($expectedMarkup, $actualMarkup);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user