@@ -117,9 +117,12 @@ protected static function parseNode($node, $element, $styles = array(), $data =
117
117
'h6 ' => array ('Heading ' , null , $ element , $ styles , null , 'Heading6 ' , null ),
118
118
'#text ' => array ('Text ' , $ node , $ element , $ styles , null , null , null ),
119
119
'strong ' => array ('Property ' , null , null , $ styles , null , 'bold ' , true ),
120
+ 'b ' => array ('Property ' , null , null , $ styles , null , 'bold ' , true ),
120
121
'em ' => array ('Property ' , null , null , $ styles , null , 'italic ' , true ),
122
+ 'i ' => array ('Property ' , null , null , $ styles , null , 'italic ' , true ),
121
123
'sup ' => array ('Property ' , null , null , $ styles , null , 'superScript ' , true ),
122
124
'sub ' => array ('Property ' , null , null , $ styles , null , 'subScript ' , true ),
125
+ 'span ' => array ('Property ' , null , null , $ styles , null , 'span ' , $ node ),
123
126
'table ' => array ('Table ' , $ node , $ element , $ styles , null , 'addTable ' , true ),
124
127
'tr ' => array ('Table ' , $ node , $ element , $ styles , null , 'addRow ' , true ),
125
128
'td ' => array ('Table ' , $ node , $ element , $ styles , null , 'addCell ' , true ),
@@ -246,7 +249,16 @@ private static function parseText($node, $element, &$styles)
246
249
*/
247
250
private static function parseProperty (&$ styles , $ argument1 , $ argument2 )
248
251
{
249
- $ styles ['font ' ][$ argument1 ] = $ argument2 ;
252
+ if ($ argument1 !== 'span ' ) {
253
+ $ styles ['font ' ][$ argument1 ] = $ argument2 ;
254
+ } else {
255
+ if (!is_null ($ argument2 ->attributes )) {
256
+ $ nodeAttr = $ argument2 ->attributes ->getNamedItem ('style ' );
257
+ if (!is_null ($ nodeAttr ) && property_exists ($ nodeAttr , 'value ' )) {
258
+ $ styles ['font ' ] = self ::parseStyle ($ nodeAttr , $ styles ['font ' ]);
259
+ }
260
+ }
261
+ }
250
262
251
263
return null ;
252
264
}
@@ -362,6 +374,20 @@ private static function parseStyle($attribute, $styles)
362
374
case 'background-color ' :
363
375
$ styles ['bgColor ' ] = trim ($ cValue , '# ' );
364
376
break ;
377
+ case 'font-weight ' :
378
+ $ tValue = false ;
379
+ if (preg_match ('#bold# ' , $ cValue )) {
380
+ $ tValue = true ; // also match bolder
381
+ }
382
+ $ styles ['bold ' ] = $ tValue ;
383
+ break ;
384
+ case 'font-style ' :
385
+ $ tValue = false ;
386
+ if (preg_match ('#(?:italic|oblique)# ' , $ cValue )) {
387
+ $ tValue = true ;
388
+ }
389
+ $ styles ['italic ' ] = $ tValue ;
390
+ break ;
365
391
}
366
392
}
367
393
0 commit comments