From 8e48a20848f9878d1f29c34e77d0f89ab0e2553f Mon Sep 17 00:00:00 2001 From: Chigozie Peter Date: Fri, 16 Feb 2024 03:49:06 +0800 Subject: [PATCH] Update Markdown.php --- src/Markdown.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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;