From 9bc85347ef074a2e4c3bf983e2b68c235adefc02 Mon Sep 17 00:00:00 2001 From: troosan Date: Sat, 14 Apr 2018 21:15:36 +0200 Subject: [PATCH] fix code formatting --- CHANGELOG.md | 1 + src/PhpWord/Shared/Html.php | 8 ++++---- tests/PhpWord/Shared/HtmlTest.php | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dcefac29b..fb07fcc243 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ v0.15.0 (?? ??? 2018) - Added support for Image text wrapping distance @troosan #1310 - Added parsing of CSS line-height and text-indent in HTML reader @troosan #1316 - Added the ability to enable gridlines and axislabels on charts @FrankMeyer #576 +- Added parsing of internal links in HTML reader @lalop #1336 ### Fixed - Fix reading of docx default style - @troosan #1238 diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index e27e706e79..7d8ee51f1d 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -723,10 +723,10 @@ private static function parseLink($node, $element, &$styles) } self::parseInlineStyle($node, $styles['font']); - if(strpos($target, '#') === 0) { - return $element->addLink(substr($target, 1), $node->textContent, $styles['font'], $styles['paragraph'], true); - } else { - return $element->addLink($target, $node->textContent, $styles['font'], $styles['paragraph']); + if (strpos($target, '#') === 0) { + return $element->addLink(substr($target, 1), $node->textContent, $styles['font'], $styles['paragraph'], true); } + + return $element->addLink($target, $node->textContent, $styles['font'], $styles['paragraph']); } } diff --git a/tests/PhpWord/Shared/HtmlTest.php b/tests/PhpWord/Shared/HtmlTest.php index c9e4b4b162..9ec2249d24 100644 --- a/tests/PhpWord/Shared/HtmlTest.php +++ b/tests/PhpWord/Shared/HtmlTest.php @@ -453,7 +453,7 @@ 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); - + $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); $section->addBookmark('bookmark'); @@ -464,7 +464,6 @@ public function testParseLink() $this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:hyperlink')); $this->assertTrue($doc->getElement('/w:document/w:body/w:p/w:hyperlink')->hasAttribute('w:anchor')); $this->assertEquals('bookmark', $doc->getElement('/w:document/w:body/w:p/w:hyperlink')->getAttribute('w:anchor')); - } public function testParseMalformedStyleIsIgnored()