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

add headerOffset

This commit is contained in:
Tobias Bengfort 2018-07-31 20:36:59 +02:00
parent 819c68899d
commit a4c297afc9
2 changed files with 22 additions and 1 deletions

View File

@ -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,

View File

@ -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);
}
}