Skip to content

Commit 7f78322

Browse files
authored
Update html.php
For acept text in line-height how "line-height:normal", etc.
1 parent a30bbbd commit 7f78322

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/PhpWord/Shared/Html.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,21 @@ protected static function parseStyle($attribute, $styles)
661661
break;
662662
case 'line-height':
663663
$matches = array();
664-
if (preg_match('/([0-9]+\.?[0-9]*[a-z]+)/', $cValue, $matches)) {
664+
if (preg_match('/([a-z]+)/', $cValue, $matches)) {
665+
//$cvalue text and not number
666+
if($cValue == 'normal') {
667+
$cValue = 1.12;
668+
$spacingLineRule = \PhpOffice\PhpWord\SimpleType\LineSpacingRule::AUTO;
669+
//we are subtracting 1 line height because the Spacing writer is adding one line
670+
$spacing = ($cValue * Paragraph::LINE_HEIGHT) - Paragraph::LINE_HEIGHT;
671+
}else{
672+
$cValue = 1.13;
673+
$spacingLineRule = \PhpOffice\PhpWord\SimpleType\LineSpacingRule::AUTO;
674+
//we are subtracting 1 line height because the Spacing writer is adding one line
675+
$spacing = ($cValue * Paragraph::LINE_HEIGHT) - Paragraph::LINE_HEIGHT;
676+
}
677+
}
678+
elseif (preg_match('/([0-9]+\.?[0-9]*[a-z]+)/', $cValue, $matches)) {
665679
//matches number with a unit, e.g. 12px, 15pt, 20mm, ...
666680
$spacingLineRule = \PhpOffice\PhpWord\SimpleType\LineSpacingRule::EXACT;
667681
$spacing = Converter::cssToTwip($matches[1]);

0 commit comments

Comments
 (0)