Skip to content

Commit

Permalink
Merge pull request #50 from BenjaminHoegh/BenjaminHoegh-patch-3
Browse files Browse the repository at this point in the history
Fixes a bug where headings still generated toc data for disabled levels
  • Loading branch information
BenjaminHoegh committed Feb 2, 2024
2 parents 39fa344 + f74eb5e commit e4308c4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/ParsedownExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,12 @@ protected function blockHeader($Line)
$id = $Block['element']['attributes']['id'] ?? $this->createAnchorID($text);

$Block['element']['attributes'] = ['id' => $id];

// Check if heading level is in the selectors
if (!in_array($level, $this->getSetting('toc.headings'])) {

This comment has been minimized.

Copy link
@nicoseba

nicoseba Feb 6, 2024

That ']' throws an error, I corrected it locally and it works.

return $Block;
}

$this->setContentsList(['text' => $text, 'id' => $id, 'level' => $level]);

return $Block;
Expand All @@ -1374,6 +1380,12 @@ protected function blockSetextHeader($Line, $Block = null)
$id = $Block['element']['attributes']['id'] ?? $this->createAnchorID($text);

$Block['element']['attributes'] = ['id' => $id];

// Check if heading level is in the selectors
if (!in_array($level, $this->getSetting('toc.headings'])) {
return $Block;
}

$this->setContentsList(['text' => $text, 'id' => $id, 'level' => $level]);

return $Block;
Expand Down

0 comments on commit e4308c4

Please sign in to comment.