From 1bd6155fd918fa3019fff77d8c4cf01b7192f079 Mon Sep 17 00:00:00 2001 From: Hannes Dorn Date: Wed, 2 Aug 2023 14:24:15 +0200 Subject: [PATCH 1/2] Hotfix: In headings hyperlinks are ignored. Added w:hyperlink to xpath filter --- src/PhpWord/Reader/Word2007/AbstractPart.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index f1bea082df..3691df1297 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -151,7 +151,11 @@ protected function readParagraph(XMLReader $xmlReader, DOMElement $domNode, $par } elseif ($headingDepth !== null) { // Heading or Title $textContent = null; - $nodes = $xmlReader->getElements('w:r', $domNode); + // 2023-08-02 hannes@dorn.cc + // $nodes = $xmlReader->getElements('w:r', $domNode); + // delivers only text paragraphs, but no hyperlinks + // I extended xpath with w:hyperlink + $nodes = $xmlReader->getElements('w:r|w:hyperlink', $domNode); if ($nodes->length === 1) { $textContent = htmlspecialchars($xmlReader->getValue('w:t', $nodes->item(0)), ENT_QUOTES, 'UTF-8'); } else { From f5f1ea35cf3445ccfc33eba8be601132553fa352 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Sat, 12 Aug 2023 12:10:59 +0200 Subject: [PATCH 2/2] Removed comments --- src/PhpWord/Reader/Word2007/AbstractPart.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php index 3691df1297..6814540290 100644 --- a/src/PhpWord/Reader/Word2007/AbstractPart.php +++ b/src/PhpWord/Reader/Word2007/AbstractPart.php @@ -151,10 +151,6 @@ protected function readParagraph(XMLReader $xmlReader, DOMElement $domNode, $par } elseif ($headingDepth !== null) { // Heading or Title $textContent = null; - // 2023-08-02 hannes@dorn.cc - // $nodes = $xmlReader->getElements('w:r', $domNode); - // delivers only text paragraphs, but no hyperlinks - // I extended xpath with w:hyperlink $nodes = $xmlReader->getElements('w:r|w:hyperlink', $domNode); if ($nodes->length === 1) { $textContent = htmlspecialchars($xmlReader->getValue('w:t', $nodes->item(0)), ENT_QUOTES, 'UTF-8');