add parsing of line-height and text-indent
This commit is contained in:
parent
4c846426ce
commit
997e21433c
|
|
@ -520,6 +520,12 @@ class Html
|
|||
case 'background-color':
|
||||
$styles['bgColor'] = trim($cValue, '#');
|
||||
break;
|
||||
case 'line-height':
|
||||
$styles['lineHeight'] = $cValue;
|
||||
break;
|
||||
case 'text-indent':
|
||||
$styles['indentation']['firstLine'] = Converter::cssToTwip($cValue);
|
||||
break;
|
||||
case 'font-weight':
|
||||
$tValue = false;
|
||||
if (preg_match('#bold#', $cValue)) {
|
||||
|
|
|
|||
|
|
@ -114,6 +114,34 @@ class HtmlTest extends \PHPUnit\Framework\TestCase
|
|||
$this->assertEquals('single', $doc->getElementAttribute('/w:document/w:body/w:p/w:r/w:rPr/w:u', 'w:val'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test line-height style
|
||||
*/
|
||||
public function testParseLineHeight()
|
||||
{
|
||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||
$section = $phpWord->addSection();
|
||||
Html::addHtml($section, '<p style="line-height: 1.5;">test</p>');
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
|
||||
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:pPr/w:spacing'));
|
||||
$this->assertEquals(240 * 1.5, $doc->getElementAttribute('/w:document/w:body/w:p/w:pPr/w:spacing', 'w:line'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test text-indent style
|
||||
*/
|
||||
public function testParseTextIndent()
|
||||
{
|
||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||
$section = $phpWord->addSection();
|
||||
Html::addHtml($section, '<p style="text-indent: 50px;">test</p>');
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
|
||||
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:pPr/w:ind'));
|
||||
$this->assertEquals(750, $doc->getElementAttribute('/w:document/w:body/w:p/w:pPr/w:ind', 'w:firstLine'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test text-align style
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue