@@ -131,7 +131,7 @@ private function init()
131
131
break ;
132
132
case 'table ' :
133
133
$ this ->parseTable ($ block );
134
- break ;
134
+ break ;
135
135
default :
136
136
break ;
137
137
}
@@ -404,13 +404,14 @@ private function parseStandardImage($block)
404
404
$ img ->setAttribute ('src ' , $ block ->data ->file ->url );
405
405
$ img ->setAttribute ('class ' , implode (' ' , $ imgAttrs ));
406
406
407
- $ figCaption = $ this ->dom ->createElement ('figcaption ' );
408
-
409
- $ figCaption ->appendChild ($ this ->html5 ->loadHTMLFragment ($ block ->data ->caption ));
410
-
411
407
$ figure ->appendChild ($ img );
412
408
413
- $ figure ->appendChild ($ figCaption );
409
+ if ($ block ->data ->caption ) {
410
+
411
+ $ figCaption = $ this ->dom ->createElement ('figcaption ' );
412
+ $ figCaption ->appendChild ($ this ->html5 ->loadHTMLFragment ($ block ->data ->caption ));
413
+ $ figure ->appendChild ($ figCaption );
414
+ }
414
415
415
416
$ this ->dom ->appendChild ($ figure );
416
417
}
@@ -439,33 +440,33 @@ private function parseTable($block)
439
440
{
440
441
$ table = $ this ->dom ->createElement ('table ' );
441
442
$ table ->setAttribute ('class ' , "{$ this ->prefix }-table " );
442
-
443
+
443
444
$ tr_top = $ this ->dom ->createElement ('tr ' );
444
445
$ thead = $ this ->dom ->createElement ('thead ' );
445
446
$ tbody = $ this ->dom ->createElement ('tbody ' );
446
447
$ thead ->appendChild ($ tr_top );
447
448
$ table ->appendChild ($ thead );
448
449
$ table ->appendChild ($ tbody );
449
450
450
-
451
451
452
- foreach ($ block ->data ->content [0 ] as $ head ){
452
+
453
+ foreach ($ block ->data ->content [0 ] as $ head ) {
453
454
$ th = $ this ->dom ->createElement ('th ' , $ head );
454
455
$ tr_top ->appendChild ($ th );
455
456
}
456
457
457
458
$ dataset = $ block ->data ->content ;
458
459
unset($ dataset [0 ]);
459
460
460
- foreach ($ dataset as $ data ) {
461
+ foreach ($ dataset as $ data ) {
461
462
$ tr = $ this ->dom ->createElement ('tr ' );
462
- foreach ($ data as $ item ){
463
+ foreach ($ data as $ item ) {
463
464
$ td = $ this ->dom ->createElement ('td ' , $ item );
464
465
$ tr ->appendChild ($ td );
465
466
}
466
467
$ tbody ->appendChild ($ tr );
467
468
}
468
-
469
+
469
470
470
471
$ this ->dom ->appendChild ($ table );
471
472
}
0 commit comments