Skip to content

Commit b14e29d

Browse files
authored
Merge pull request #1190 from phpDocumentor/backport/1.x/pr-1189
[1.x] Merge pull request #1189 from phpDocumentor/bugfix/titles
2 parents f8c6cf3 + 5be7d42 commit b14e29d

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

packages/guides/src/Compiler/NodeTransformers/CollectLinkTargetsTransformer.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,16 @@ public function enterNode(Node $node, CompilerContextInterface $compilerContext)
8787
$currentDocument = $this->documentStack->top();
8888
Assert::notNull($currentDocument);
8989
$anchorName = $node->getId();
90+
foreach ($node->getChildren() as $childNode) {
91+
if ($childNode instanceof AnchorNode) {
92+
$anchorName = $childNode->getValue();
93+
break;
94+
}
95+
}
96+
9097
try {
9198
$compilerContext->getProjectNode()->addLinkTarget(
92-
$anchorName,
99+
$node->getId(),
93100
new InternalTarget(
94101
$currentDocument->getFilePath(),
95102
$anchorName,

tests/Integration/tests/anchor/anchor-to-page/expected/objects.inv.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"overview": [
4444
"-",
4545
"-",
46-
"sphinx-overview.html#overview",
46+
"sphinx-overview.html#sphinx-overview",
4747
"Overview"
4848
]
4949
}

tests/Integration/tests/images/image-target/expected/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ <h2>Link image to reference</h2>
3535
</div>
3636
<div class="section" id="link-image-to-reference">
3737
<h2>Link image to reference</h2>
38-
<a href="#document-title"><img
38+
<a href="#start"><img
3939
src="images/hero2-illustration.svg"
4040
width="400" alt="Alternative text" />
4141
</a>

tests/Integration/tests/interlink/inventory_ref_json/expected/objects.inv.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@
6161
"document-title": [
6262
"My Project",
6363
"3.1.4",
64-
"index.html#document-title",
64+
"index.html#my_index",
6565
"Document Title"
6666
],
6767
"page-1": [
6868
"My Project",
6969
"3.1.4",
70-
"page1.html#page-1",
70+
"page1.html#my_cool_page",
7171
"Page 1"
7272
],
7373
"page-2": [
@@ -85,7 +85,7 @@
8585
"subpage-1": [
8686
"My Project",
8787
"3.1.4",
88-
"subfolder\/subpage1.html#subpage-1",
88+
"subfolder\/subpage1.html#another_cool_page",
8989
"Subpage 1"
9090
],
9191
"subpage-2": [

tests/Integration/tests/references/reference-to-anchor/expected/objects.inv.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"flexforms-1": [
4444
"-",
4545
"-",
46-
"index.html#flexforms-1",
46+
"index.html#flexforms",
4747
"FlexForms"
4848
],
4949
"yet-another-page": [

0 commit comments

Comments
 (0)