@@ -109,11 +109,11 @@ protected static function parseInlineStyle($node, $styles = array())
109
109
break ;
110
110
case 'width ' :
111
111
// tables, cells
112
- if (false !== strpos ($ val , '% ' )){
113
- // e.g. <table width="100%"> or <td width=50%>
112
+ if (false !== strpos ($ val , '% ' )) {
113
+ // e.g. <table width="100%"> or <td width=" 50%" >
114
114
$ styles ['width ' ] = intval ($ val ) * 50 ;
115
115
$ styles ['unit ' ] = \PhpOffice \PhpWord \SimpleType \TblWidth::PERCENT ;
116
- }else {
116
+ } else {
117
117
// e.g. <table width="250> where "250" = 250px (always pixels)
118
118
$ styles ['width ' ] = Converter::pixelToTwip ($ val );
119
119
$ styles ['unit ' ] = \PhpOffice \PhpWord \SimpleType \TblWidth::TWIP ;
@@ -472,10 +472,10 @@ protected static function parseList($node, $element, &$styles, &$data)
472
472
$ levels = $ style ->getLevels ();
473
473
/** @var \PhpOffice\PhpWord\Style\NumberingLevel */
474
474
$ level = $ levels [0 ];
475
- if ($ start > 0 ){
475
+ if ($ start > 0 ) {
476
476
$ level ->setStart ($ start );
477
477
}
478
- if ($ type && !!($ type = self ::mapListType ($ type ))){
478
+ if ($ type && !!($ type = self ::mapListType ($ type ))) {
479
479
$ level ->setFormat ($ type );
480
480
}
481
481
}
@@ -675,10 +675,10 @@ protected static function parseStyle($attribute, $styles)
675
675
// must have exact order [width color style], e.g. "1px #0011CC solid" or "2pt green solid"
676
676
// Word does not accept shortened hex colors e.g. #CCC, only full e.g. #CCCCCC
677
677
if (preg_match ('/([0-9]+[^0-9]*)\s+(\#[a-fA-F0-9]+|[a-zA-Z]+)\s+([a-z]+)/ ' , $ cValue , $ matches )) {
678
- if (false !== strpos ($ cKey , '- ' )){
678
+ if (false !== strpos ($ cKey , '- ' )) {
679
679
$ which = explode ('- ' , $ cKey )[1 ];
680
680
$ which = ucfirst ($ which ); // e.g. bottom -> Bottom
681
- }else {
681
+ } else {
682
682
$ which = '' ;
683
683
}
684
684
// normalization: in HTML 1px means tinest possible line width, so we cannot convert 1px -> 15 twips, coz line'd be bold, we use smallest twip instead
@@ -883,6 +883,10 @@ protected static function mapAlignVertical($alignment)
883
883
case 'baseline ' :
884
884
return 'top ' ;
885
885
default :
886
+ // @discuss - which one should apply:
887
+ // - Word uses default vert. alignment: top
888
+ // - all browsers use default vert. alignment: middle
889
+ // Returning empty string means attribute wont be set so use Word default (top).
886
890
return '' ;
887
891
}
888
892
}
0 commit comments