diff --git a/src/Markdown.php b/src/Markdown.php index 6222a9f..582e04b 100644 --- a/src/Markdown.php +++ b/src/Markdown.php @@ -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;