diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1b50e601..344517c7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,7 +16,8 @@ v0.15.0 (?? ??? 2018)
- Fix the size unit of when parsing html images - @troosan #1254
- Fixed HTML parsing of nested lists - @troosan #1265
- Save PNG alpha information when using remote images. @samsullivan #779
-- fix parsing of `` tag. @troosan #1274
+- Fix parsing of `` tag. @troosan #1274
+- Bookmark are not writton as internal link in html writer @troosan #1263
diff --git a/src/PhpWord/Writer/HTML/Element/Bookmark.php b/src/PhpWord/Writer/HTML/Element/Bookmark.php
new file mode 100644
index 00000000..649cc7b8
--- /dev/null
+++ b/src/PhpWord/Writer/HTML/Element/Bookmark.php
@@ -0,0 +1,45 @@
+element instanceof \PhpOffice\PhpWord\Element\Bookmark) {
+ return '';
+ }
+
+ $content = '';
+ $content .= $this->writeOpening();
+ $content .= "element->getName()}\"/>";
+ $content .= $this->writeClosing();
+
+ return $content;
+ }
+}
diff --git a/src/PhpWord/Writer/HTML/Element/Link.php b/src/PhpWord/Writer/HTML/Element/Link.php
index bdea985a..f29880d4 100644
--- a/src/PhpWord/Writer/HTML/Element/Link.php
+++ b/src/PhpWord/Writer/HTML/Element/Link.php
@@ -37,12 +37,12 @@ class Link extends Text
return '';
}
- $content = '';
- $content .= $this->writeOpening();
+ $prefix = $this->element->isInternal() ? '#' : '';
+ $content = $this->writeOpening();
if (Settings::isOutputEscapingEnabled()) {
- $content .= "escaper->escapeHtmlAttr($this->element->getSource())}\">{$this->escaper->escapeHtml($this->element->getText())}";
+ $content .= "escaper->escapeHtmlAttr($this->element->getSource())}\">{$this->escaper->escapeHtml($this->element->getText())}";
} else {
- $content .= "element->getSource()}\">{$this->element->getText()}";
+ $content .= "element->getSource()}\">{$this->element->getText()}";
}
$content .= $this->writeClosing();
diff --git a/tests/PhpWord/Writer/HTML/ElementTest.php b/tests/PhpWord/Writer/HTML/ElementTest.php
index 86856d5c..fc092ba3 100644
--- a/tests/PhpWord/Writer/HTML/ElementTest.php
+++ b/tests/PhpWord/Writer/HTML/ElementTest.php
@@ -31,7 +31,7 @@ class ElementTest extends \PHPUnit\Framework\TestCase
*/
public function testUnmatchedElements()
{
- $elements = array('Container', 'Footnote', 'Image', 'Link', 'ListItem', 'Table', 'Title');
+ $elements = array('Container', 'Footnote', 'Image', 'Link', 'ListItem', 'Table', 'Title', 'Bookmark');
foreach ($elements as $element) {
$objectClass = 'PhpOffice\\PhpWord\\Writer\\HTML\\Element\\' . $element;
$parentWriter = new HTML();
diff --git a/tests/PhpWord/Writer/HTMLTest.php b/tests/PhpWord/Writer/HTMLTest.php
index bdfc44e3..f2bc7175 100644
--- a/tests/PhpWord/Writer/HTMLTest.php
+++ b/tests/PhpWord/Writer/HTMLTest.php
@@ -73,6 +73,7 @@ class HTMLTest extends \PHPUnit\Framework\TestCase
);
$phpWord->addParagraphStyle('Paragraph', array('alignment' => Jc::CENTER, 'spaceAfter' => 20, 'spaceBefore' => 20));
$section = $phpWord->addSection();
+ $section->addBookmark('top');
$section->addText(htmlspecialchars('Test 1', ENT_COMPAT, 'UTF-8'), 'Font', 'Paragraph');
$section->addTextBreak();
$section->addText(
@@ -128,6 +129,7 @@ class HTMLTest extends \PHPUnit\Framework\TestCase
$cell->addFootnote();
$cell->addEndnote();
$cell = $table->addRow()->addCell();
+ $section->addLink('top', 'back to top', null, null, true);
$writer = new HTML($phpWord);