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

Add Option minHeaderLevel

Add a new option to define the minimal Header level to be used
e.g. if the option `->minHeaderLevel(3)` a header defined with a single hash `# heading` will be parsed as `<h3>heading</h3>`
This commit is contained in:
Martin Heinze 2022-06-15 22:07:29 +02:00 committed by GitHub
parent 6598f3860c
commit b8d675d7b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,6 +83,15 @@ class Parsedown
protected $urlsLinked = true; protected $urlsLinked = true;
function minHeaderLevel($minHeaderLevel)
{
$this->minHeaderLevel = (int) $minHeaderLevel;
return $this;
}
protected $minHeaderLevel;
function setSafeMode($safeMode) function setSafeMode($safeMode)
{ {
$this->safeMode = (bool) $safeMode; $this->safeMode = (bool) $safeMode;
@ -540,6 +549,8 @@ class Parsedown
{ {
$level = strspn($Line['text'], '#'); $level = strspn($Line['text'], '#');
$level = (isset($this->minHeaderLevel) ? $this->minHeaderLevel + $level - 1 : $level);
if ($level > 6) if ($level > 6)
{ {
return; return;