Skip to content

Commit

Permalink
Merge pull request #1190 from phpDocumentor/backport/1.x/pr-1189
Browse files Browse the repository at this point in the history
[1.x] Merge pull request #1189 from phpDocumentor/bugfix/titles
  • Loading branch information
phpdoc-bot authored Jan 6, 2025
2 parents f8c6cf3 + 5be7d42 commit b14e29d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,16 @@ public function enterNode(Node $node, CompilerContextInterface $compilerContext)
$currentDocument = $this->documentStack->top();
Assert::notNull($currentDocument);
$anchorName = $node->getId();
foreach ($node->getChildren() as $childNode) {
if ($childNode instanceof AnchorNode) {
$anchorName = $childNode->getValue();
break;
}
}

try {
$compilerContext->getProjectNode()->addLinkTarget(
$anchorName,
$node->getId(),
new InternalTarget(
$currentDocument->getFilePath(),
$anchorName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"overview": [
"-",
"-",
"sphinx-overview.html#overview",
"sphinx-overview.html#sphinx-overview",
"Overview"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h2>Link image to reference</h2>
</div>
<div class="section" id="link-image-to-reference">
<h2>Link image to reference</h2>
<a href="#document-title"><img
<a href="#start"><img
src="images/hero2-illustration.svg"
width="400" alt="Alternative text" />
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@
"document-title": [
"My Project",
"3.1.4",
"index.html#document-title",
"index.html#my_index",
"Document Title"
],
"page-1": [
"My Project",
"3.1.4",
"page1.html#page-1",
"page1.html#my_cool_page",
"Page 1"
],
"page-2": [
Expand All @@ -85,7 +85,7 @@
"subpage-1": [
"My Project",
"3.1.4",
"subfolder\/subpage1.html#subpage-1",
"subfolder\/subpage1.html#another_cool_page",
"Subpage 1"
],
"subpage-2": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"flexforms-1": [
"-",
"-",
"index.html#flexforms-1",
"index.html#flexforms",
"FlexForms"
],
"yet-another-page": [
Expand Down

0 comments on commit b14e29d

Please sign in to comment.