Skip to content

Commit 505e26b

Browse files
authored
Merge pull request #709 from humanmade/backport-704-to-v25-branch
[Backport v25-branch] Upgrade erusev/parsedown from 1.7.4 to 1.8.0
2 parents d2ebc7e + 6cc2265 commit 505e26b

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)