Skip to content

Commit 39345e1

Browse files
committed
[BUGFIX] Fix interlink target URLs for links with anchor prefix
(cherry picked from commit a821ca9) # Conflicts: # tests/Integration/tests-full/markdown-full/front-matter-md/expected/index.html
1 parent cd2fcb9 commit 39345e1

File tree

40 files changed

+163
-43
lines changed

40 files changed

+163
-43
lines changed

packages/guides/src/Renderer/InterlinkObjectsRenderer.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace phpDocumentor\Guides\Renderer;
1515

1616
use phpDocumentor\Guides\Handlers\RenderCommand;
17+
use phpDocumentor\Guides\Meta\InternalTarget;
1718
use phpDocumentor\Guides\ReferenceResolvers\DocumentNameResolverInterface;
1819
use phpDocumentor\Guides\RenderContext;
1920
use phpDocumentor\Guides\Renderer\UrlGenerator\UrlGeneratorInterface;
@@ -73,6 +74,13 @@ public function render(RenderCommand $renderCommand): void
7374
'',
7475
$this->urlGenerator->createFileUrl($context, $internalTarget->getDocumentPath(), $internalTarget->getAnchor()),
7576
);
77+
if ($internalTarget instanceof InternalTarget) {
78+
$url = $this->documentNameResolver->canonicalUrl(
79+
'',
80+
$this->urlGenerator->createFileUrl($context, $internalTarget->getDocumentPath(), $internalTarget->getPrefix() . $internalTarget->getAnchor()),
81+
);
82+
}
83+
7684
$inventory[$linkType][$key] = [
7785
$projectNode->getTitle() ?? '-',
7886
$projectNode->getVersion() ?? '-',

tests/Integration/tests-full/markdown-full/default-menu-md/expected/anotherPage.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
</ol>
7272
</nav>
7373
<!-- content start -->
74-
<div class="section" id="another-page">
74+
75+
<div class="section" id="another-page">
7576
<h1>Another Page</h1>
7677

7778
<p>Lorem Ipsum Dolor.</p>

tests/Integration/tests-full/markdown-full/default-menu-md/expected/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
</ol>
7171
</nav>
7272
<!-- content start -->
73-
<div class="section" id="document-title">
73+
74+
<div class="section" id="document-title">
7475
<h1>Document Title</h1>
7576

7677
<p>Lorem Ipsum Dolor.</p>

tests/Integration/tests-full/markdown-full/default-menu-md/expected/somePage.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
</ol>
7272
</nav>
7373
<!-- content start -->
74-
<div class="section" id="some-page">
74+
75+
<div class="section" id="some-page">
7576
<h1>Some Page</h1>
7677

7778
<p>Lorem Ipsum <code>Dolor</code>.</p>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<!DOCTYPE html>
2+
<html class="no-js" lang="en">
3+
<head>
4+
<title>Front Matter</title>
5+
<!-- Required meta tags -->
6+
<meta charset="utf-8">
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
9+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
10+
</head>
11+
<body>
12+
<header class="">
13+
14+
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
15+
<div class="container">
16+
17+
<a class="navbar-brand" href="#">Navbar</a>
18+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
19+
<span class="navbar-toggler-icon"></span>
20+
</button>
21+
<div class="collapse navbar-collapse" id="navbarSupportedContent">
22+
23+
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
24+
</ul>
25+
26+
</div>
27+
</div>
28+
</nav>
29+
</header>
30+
<main id="main-content">
31+
<div class="container">
32+
<div class="container">
33+
<div class="row">
34+
<div class="col-lg-3">
35+
<nav class="nav flex-column">
36+
<ul class="menu-level-main">
37+
</ul>
38+
</nav>
39+
40+
</div>
41+
<div class="col-lg-9">
42+
43+
<nav aria-label="breadcrumb">
44+
<ol class="breadcrumb">
45+
<li class="breadcrumb-item"><a href="#">Document Title</a></li>
46+
</ol>
47+
</nav>
48+
<!-- content start -->
49+
50+
<div class="section" id="document-title">
51+
<h1>Document Title</h1>
52+
53+
<p>Lorem Ipsum Dolor.</p>
54+
55+
</div>
56+
<!-- content end -->
57+
</div>
58+
</div>
59+
</div>
60+
</div>
61+
</main>
62+
63+
<!-- Optional JavaScript; choose one of the two! -->
64+
65+
<!-- Option 1: Bootstrap Bundle with Popper -->
66+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
67+
68+
<!-- Option 2: Separate Popper and Bootstrap JS -->
69+
<!--
70+
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
71+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
72+
-->
73+
</body>
74+
</html>

tests/Integration/tests-full/markdown-full/multi-nested-menu-md/expected/dir2/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@
140140
</ol>
141141
</nav>
142142
<!-- content start -->
143-
<div class="section" id="dir-2-title">
143+
144+
<div class="section" id="dir-2-title">
144145
<h1>Dir 2 Title</h1>
145146

146147
<p>Lorem Ipsum Dolor.</p>

tests/Integration/tests-full/markdown-full/multi-nested-menu-md/expected/dir2/somePage.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@
141141
</ol>
142142
</nav>
143143
<!-- content start -->
144-
<div class="section" id="some-page-in-dir-2">
144+
145+
<div class="section" id="some-page-in-dir-2">
145146
<h1>Some Page in dir 2</h1>
146147

147148
<p>Lorem Ipsum <code>Dolor</code>.</p>

tests/Integration/tests-full/markdown-full/multi-nested-menu-md/expected/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@
139139
</ol>
140140
</nav>
141141
<!-- content start -->
142-
<div class="section" id="document-title">
142+
143+
<div class="section" id="document-title">
143144
<h1>Document Title</h1>
144145

145146
<p>Lorem Ipsum Dolor.</p>

tests/Integration/tests-full/markdown-full/nested-menu-md/expected/dir2/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@
117117
</ol>
118118
</nav>
119119
<!-- content start -->
120-
<div class="section" id="dir-2-title">
120+
121+
<div class="section" id="dir-2-title">
121122
<h1>Dir 2 Title</h1>
122123

123124
<p>Lorem Ipsum Dolor.</p>

tests/Integration/tests-full/markdown-full/nested-menu-md/expected/dir2/somePage.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@
118118
</ol>
119119
</nav>
120120
<!-- content start -->
121-
<div class="section" id="some-page-in-dir-2">
121+
122+
<div class="section" id="some-page-in-dir-2">
122123
<h1>Some Page in dir 2</h1>
123124

124125
<p>Lorem Ipsum <code>Dolor</code>.</p>

0 commit comments

Comments
 (0)