Skip to content

Commit

Permalink
Update Markdown.php
Browse files Browse the repository at this point in the history
  • Loading branch information
peterujah authored Feb 15, 2024
1 parent af58452 commit 8e48a20
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,17 @@ public function getTableOfContents(): array
* Add attribute to table of contents
*
* @param array $Element
* @param string $text
* @param string|array $text
*
* @return string
*/
protected function addAttribute(array $Element, string $text): string
protected function addAttribute(array $Element, string|array $text): string
{
$attr = '';

if(is_array($text)){
$text = $text['text'] ?? '';
}

if($this->enableTableOfContents && in_array($Element['name'], $this->tableHeadings) && isset($Element['attr'])){
$attrValue = self::toKebabCase($text);
$this->tableOfContents[$attrValue] = $text;
Expand Down

0 comments on commit 8e48a20

Please sign in to comment.