Skip to content

Commit 6cc2265

Browse files
mikelittleclaude
authored andcommitted
Upgrade erusev/parsedown from 1.7.4 to 1.8.0
Update the parsedown dependency to the latest stable release (1.8.0) which includes security fixes and improved CommonMark compliance. Update MarkdownParser::blockHeader() to use the 1.8.0 element structure where handler is now an array with function/argument/destination keys, and child elements use the 'elements' key directly. This also fixes a pre-existing bug where header anchor IDs were empty because sanitize_title_with_dashes() was processing raw Parsedown inline tokens instead of plain text. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> (cherry picked from commit f698bcb)
1 parent d2ebc7e commit 6cc2265

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"require": {
2121
"php": ">=8.2",
22-
"erusev/parsedown": "~1.7.4",
22+
"erusev/parsedown": "~1.8.0",
2323
"mustangostang/spyc": "^0.6.3"
2424
},
2525
"extra": {

inc/class-markdownparser.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,17 @@ protected function inlineInternalLink( $result, $parts ) {
176176
*/
177177
protected function blockHeader( $data ) {
178178
$block = parent::blockHeader( $data );
179-
$id = sanitize_title_with_dashes( $block['element']['text'] );
179+
if ( empty( $block ) ) {
180+
return $block;
181+
}
182+
183+
$text = $block['element']['handler']['argument'];
184+
$id = sanitize_title_with_dashes( $text );
180185

181186
// Use a manual ID if provided.
182-
if ( preg_match( '/^(.+) ?\{#(.+?)\}$/', $block['element']['text'], $matches ) ) {
187+
if ( preg_match( '/^(.+) ?\{#(.+?)\}$/', $text, $matches ) ) {
183188
$id = $matches[2];
184-
$block['element']['text'] = $matches[1];
189+
$block['element']['handler']['argument'] = $matches[1];
185190
}
186191

187192
return [
@@ -192,8 +197,7 @@ protected function blockHeader( $data ) {
192197
'id' => $id,
193198
'class' => 'header-anchor',
194199
],
195-
'handler' => 'elements',
196-
'text' => [ $block['element'] ],
200+
'elements' => [ $block['element'] ],
197201
],
198202
];
199203
}

0 commit comments

Comments
 (0)