@@ -119,9 +119,12 @@ protected static function parseNode($node, $element, $styles = array(), $data =
119
119
'h6 ' => array ('Heading ' , null , $ element , $ styles , null , 'Heading6 ' , null ),
120
120
'#text ' => array ('Text ' , $ node , $ element , $ styles , null , null , null ),
121
121
'strong ' => array ('Property ' , null , null , $ styles , null , 'bold ' , true ),
122
+ 'b ' => array ('Property ' , null , null , $ styles , null , 'bold ' , true ),
122
123
'em ' => array ('Property ' , null , null , $ styles , null , 'italic ' , true ),
124
+ 'i ' => array ('Property ' , null , null , $ styles , null , 'italic ' , true ),
123
125
'sup ' => array ('Property ' , null , null , $ styles , null , 'superScript ' , true ),
124
126
'sub ' => array ('Property ' , null , null , $ styles , null , 'subScript ' , true ),
127
+ 'span ' => array ('Property ' , null , null , $ styles , null , 'span ' , $ node ),
125
128
'table ' => array ('Table ' , $ node , $ element , $ styles , null , 'addTable ' , true ),
126
129
'tr ' => array ('Table ' , $ node , $ element , $ styles , null , 'addRow ' , true ),
127
130
'td ' => array ('Table ' , $ node , $ element , $ styles , null , 'addCell ' , true ),
@@ -251,7 +254,16 @@ private static function parseText($node, $element, &$styles)
251
254
*/
252
255
private static function parseProperty (&$ styles , $ argument1 , $ argument2 )
253
256
{
254
- $ styles ['font ' ][$ argument1 ] = $ argument2 ;
257
+ if ($ argument1 !== 'span ' ) {
258
+ $ styles ['font ' ][$ argument1 ] = $ argument2 ;
259
+ } else {
260
+ if (!is_null ($ argument2 ->attributes )) {
261
+ $ nodeAttr = $ argument2 ->attributes ->getNamedItem ('style ' );
262
+ if (!is_null ($ nodeAttr ) && property_exists ($ nodeAttr , 'value ' )) {
263
+ $ styles ['font ' ] = self ::parseStyle ($ nodeAttr , $ styles ['font ' ]);
264
+ }
265
+ }
266
+ }
255
267
256
268
return null ;
257
269
}
@@ -369,6 +381,20 @@ private static function parseStyle($attribute, $styles)
369
381
case 'background-color ' :
370
382
$ styles ['bgColor ' ] = trim ($ cValue , "# " );
371
383
break ;
384
+ case 'font-weight ' :
385
+ $ tValue = false ;
386
+ if (preg_match ('#bold# ' , $ cValue )) {
387
+ $ tValue = true ; // also match bolder
388
+ }
389
+ $ styles ['bold ' ] = $ tValue ;
390
+ break ;
391
+ case 'font-style ' :
392
+ $ tValue = false ;
393
+ if (preg_match ('#(?:italic|oblique)# ' , $ cValue )) {
394
+ $ tValue = true ;
395
+ }
396
+ $ styles ['italic ' ] = $ tValue ;
397
+ break ;
372
398
}
373
399
}
374
400
0 commit comments