diff --git a/composer.json b/composer.json index 51655a25..4fa85a9b 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=8.2", - "erusev/parsedown": "~1.7.4", + "erusev/parsedown": "~1.8.0", "mustangostang/spyc": "^0.6.3" }, "extra": { diff --git a/inc/class-markdownparser.php b/inc/class-markdownparser.php index 1702a76f..3de2b498 100644 --- a/inc/class-markdownparser.php +++ b/inc/class-markdownparser.php @@ -176,12 +176,17 @@ protected function inlineInternalLink( $result, $parts ) { */ protected function blockHeader( $data ) { $block = parent::blockHeader( $data ); - $id = sanitize_title_with_dashes( $block['element']['text'] ); + if ( empty( $block ) ) { + return $block; + } + + $text = $block['element']['handler']['argument']; + $id = sanitize_title_with_dashes( $text ); // Use a manual ID if provided. - if ( preg_match( '/^(.+) ?\{#(.+?)\}$/', $block['element']['text'], $matches ) ) { + if ( preg_match( '/^(.+) ?\{#(.+?)\}$/', $text, $matches ) ) { $id = $matches[2]; - $block['element']['text'] = $matches[1]; + $block['element']['handler']['argument'] = $matches[1]; } return [ @@ -192,8 +197,7 @@ protected function blockHeader( $data ) { 'id' => $id, 'class' => 'header-anchor', ], - 'handler' => 'elements', - 'text' => [ $block['element'] ], + 'elements' => [ $block['element'] ], ], ]; }