Skip to content

Commit

Permalink
fix parsing of link style
Browse files Browse the repository at this point in the history
  • Loading branch information
troosan committed Apr 25, 2018
1 parent 84fa440 commit 94be56b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion samples/Sample_26_Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
$html .= '<p>Some well-formed HTML snippet needs to be used</p>';
$html .= '<p>With for example <strong>some<sup>1</sup> <em>inline</em> formatting</strong><sub>1</sub></p>';

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/Shared/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ private static function parseLink($node, $element, &$styles)
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);
Expand Down
2 changes: 2 additions & 0 deletions tests/PhpWord/Shared/HtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,8 @@ public function testParseLink()

$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();
Expand Down

0 comments on commit 94be56b

Please sign in to comment.