From 94be56b0ec6fcbb43d8a48bae9e74d3d93c5beb7 Mon Sep 17 00:00:00 2001 From: troosan Date: Wed, 25 Apr 2018 23:57:07 +0200 Subject: [PATCH] fix parsing of link style --- samples/Sample_26_Html.php | 2 +- src/PhpWord/Shared/Html.php | 2 +- tests/PhpWord/Shared/HtmlTest.php | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/samples/Sample_26_Html.php b/samples/Sample_26_Html.php index d8763805..e1823c43 100644 --- a/samples/Sample_26_Html.php +++ b/samples/Sample_26_Html.php @@ -11,7 +11,7 @@ $html = '

Adding element via HTML

'; $html .= '

Some well-formed HTML snippet needs to be used

'; $html .= '

With for example some1 inline formatting1

'; -$html .= '

A link to Read the docs

'; +$html .= '

A link to Read the docs

'; $html .= '

היי, זה פסקה מימין לשמאל

'; diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 7d8ee51f..cbdcecd5 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -721,7 +721,7 @@ class Html break; } } - self::parseInlineStyle($node, $styles['font']); + $styles['font'] = self::parseInlineStyle($node, $styles['font']); if (strpos($target, '#') === 0) { return $element->addLink(substr($target, 1), $node->textContent, $styles['font'], $styles['paragraph'], true); diff --git a/tests/PhpWord/Shared/HtmlTest.php b/tests/PhpWord/Shared/HtmlTest.php index f07b3f99..b61418e0 100644 --- a/tests/PhpWord/Shared/HtmlTest.php +++ b/tests/PhpWord/Shared/HtmlTest.php @@ -458,6 +458,8 @@ class HtmlTest extends \PHPUnit\Framework\TestCase $this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:hyperlink')); $this->assertEquals('link text', $doc->getElement('/w:document/w:body/w:p/w:hyperlink/w:r/w:t')->nodeValue); + $this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:hyperlink/w:r/w:rPr/w:u')); + $this->assertEquals('single', $doc->getElementAttribute('/w:document/w:body/w:p/w:hyperlink/w:r/w:rPr/w:u', 'w:val')); $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection();