Skip to content

Commit 440fb33

Browse files
committed
fix: fix tests
1 parent fe924e4 commit 440fb33

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

includes/EmbedVideo.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,22 @@ private function init(): void {
507507
* @return void
508508
*/
509509
private function setDescription( string $description, Parser $parser ): void {
510-
$this->description = ( !$description ? false : $parser->recursiveTagParseFully( $description ) );
510+
if ( !$description ) {
511+
$this->description = false;
512+
return;
513+
}
514+
515+
// Parse the description using the MediaWiki parser to allow wikitext,
516+
// but strip a single outer <p> wrapper so the caption matches
517+
// expectations like "<figcaption>Example description</figcaption>".
518+
$parsed = $parser->recursiveTagParseFully( $description );
519+
$trimmed = trim( $parsed );
520+
if ( preg_match( '/^<p>(.*)<\/p>$/s', $trimmed, $m ) ) {
521+
$content = $m[1];
522+
} else {
523+
$content = $trimmed;
524+
}
525+
$this->description = trim( $content );
511526
}
512527

513528
/**

0 commit comments

Comments
 (0)