Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Option minHeaderLevel #834

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>`
nyphis authored Jun 15, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit b8d675d7b48e4f136ed8f39bd9a2a49437c8f018
11 changes: 11 additions & 0 deletions Parsedown.php
Original file line number Diff line number Diff line change
@@ -83,6 +83,15 @@ function setUrlsLinked($urlsLinked)

protected $urlsLinked = true;

function minHeaderLevel($minHeaderLevel)
{
$this->minHeaderLevel = (int) $minHeaderLevel;

return $this;
}

protected $minHeaderLevel;

function setSafeMode($safeMode)
{
$this->safeMode = (bool) $safeMode;
@@ -540,6 +549,8 @@ protected function blockHeader($Line)
{
$level = strspn($Line['text'], '#');

$level = (isset($this->minHeaderLevel) ? $this->minHeaderLevel + $level - 1 : $level);

if ($level > 6)
{
return;