Skip to content

Commit 94be56b

Browse files
committed
fix parsing of link style
1 parent 84fa440 commit 94be56b

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

samples/Sample_26_Html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
$html .= '<p>Some well-formed HTML snippet needs to be used</p>';
1212
$html .= '<p>With for example <strong>some<sup>1</sup> <em>inline</em> formatting</strong><sub>1</sub></p>';
1313

14-
$html .= '<p>A link to <a href="http://phpword.readthedocs.io/">Read the docs</a></p>';
14+
$html .= '<p>A link to <a href="http://phpword.readthedocs.io/" style="text-decoration: underline">Read the docs</a></p>';
1515

1616
$html .= '<p lang="he-IL" style="text-align: right; direction: rtl">היי, זה פסקה מימין לשמאל</p>';
1717

src/PhpWord/Shared/Html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ private static function parseLink($node, $element, &$styles)
721721
break;
722722
}
723723
}
724-
self::parseInlineStyle($node, $styles['font']);
724+
$styles['font'] = self::parseInlineStyle($node, $styles['font']);
725725

726726
if (strpos($target, '#') === 0) {
727727
return $element->addLink(substr($target, 1), $node->textContent, $styles['font'], $styles['paragraph'], true);

tests/PhpWord/Shared/HtmlTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,8 @@ public function testParseLink()
458458

459459
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:hyperlink'));
460460
$this->assertEquals('link text', $doc->getElement('/w:document/w:body/w:p/w:hyperlink/w:r/w:t')->nodeValue);
461+
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:hyperlink/w:r/w:rPr/w:u'));
462+
$this->assertEquals('single', $doc->getElementAttribute('/w:document/w:body/w:p/w:hyperlink/w:r/w:rPr/w:u', 'w:val'));
461463

462464
$phpWord = new \PhpOffice\PhpWord\PhpWord();
463465
$section = $phpWord->addSection();

0 commit comments

Comments
 (0)