File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -507,7 +507,22 @@ private function init(): void {
507
507
* @return void
508
508
*/
509
509
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 );
511
526
}
512
527
513
528
/**
You can’t perform that action at this time.
0 commit comments