Skip to content

Commit d438840

Browse files
committed
[BUGFIX] Normalize Anchors in Permalink dialog
1 parent 268920e commit d438840

File tree

5 files changed

+54
-3
lines changed

5 files changed

+54
-3
lines changed

Documentation-rendertest/Admonitions-and-buttons/Index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.. include:: /Includes.rst.txt
22

3+
.. _Adminitions_And_Buttons:
34

45
=======================
56
Admonitions and buttons

packages/typo3-docs-theme/src/Twig/TwigExtension.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use phpDocumentor\Guides\Nodes\Node;
1515
use phpDocumentor\Guides\Nodes\PrefixedLinkTargetNode;
1616
use phpDocumentor\Guides\Nodes\SectionNode;
17+
use phpDocumentor\Guides\ReferenceResolvers\AnchorNormalizer;
1718
use phpDocumentor\Guides\ReferenceResolvers\DocumentNameResolverInterface;
1819
use phpDocumentor\Guides\RenderContext;
1920
use phpDocumentor\Guides\Renderer\UrlGenerator\UrlGeneratorInterface;
@@ -60,6 +61,7 @@ public function __construct(
6061
private readonly Typo3DocsThemeSettings $themeSettings,
6162
private readonly DocumentNameResolverInterface $documentNameResolver,
6263
private readonly Typo3VersionService $typo3VersionService,
64+
private readonly AnchorNormalizer $anchorNormalizer,
6365
) {
6466
if (strlen((string)getenv('GITHUB_ACTIONS')) > 0 && strlen((string)getenv('TYPO3AZUREEDGEURIVERSION')) > 0 && !isset($_ENV['CI_PHPUNIT'])) {
6567
// CI gets special treatment, then we use a fixed URI for assets.
@@ -255,7 +257,7 @@ public function getAnchorIdOfSection(array $context, SectionNode $sectionNode):
255257
{
256258
foreach ($sectionNode->getChildren() as $childNode) {
257259
if ($childNode instanceof AnchorNode) {
258-
return $childNode->toString();
260+
return $this->anchorNormalizer->reduceAnchor($childNode->toString());
259261
}
260262
}
261263
return '';

tests/Integration/tests-full/link-wizard/expected/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@
117117
<article class="document" itemscope="itemscope" itemtype="http://schema.org/Article" role="main">
118118
<div itemprop="articleBody">
119119
<!-- content start -->
120-
<section class="section" id="document-title" data-rst-anchor="my_document">
120+
<section class="section" id="document-title" data-rst-anchor="my-document">
121121
<a id="my_document"></a>
122122
<h1>Document Title<a class="headerlink" href="#document-title" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"><i class="fa-solid fa-paragraph"></i></a></h1>
123123

124124
<p>Lorem Ipsum Dolor.</p>
125125

126-
<section class="section" id="section-1" data-rst-anchor="my_section">
126+
<section class="section" id="section-1" data-rst-anchor="my-section">
127127
<a id="my_section"></a>
128128
<h2>Section 1<a class="headerlink" href="#section-1" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"><i class="fa-solid fa-paragraph"></i></a></h2>
129129
</section>

tests/Integration/tests/confval/confval-basic/expected/index.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,44 @@ <h3 class="sr-only">demo</h3>
4343

4444
<p>See also <a href="#confval-demo">demo</a> or <a href="#confval-demo">demo</a>.</p>
4545

46+
<section data-search-title="demo"
47+
data-search-id="confval-some-other-demo"
48+
data-search-facet="Option"
49+
class="confval-section"
50+
>
51+
<h3 class="sr-only">demo</h3>
52+
<dl class="confval">
53+
<dt id="confval-some-other-demo" class="d-flex justify-content-between">
54+
<div class="confval-header">
55+
<code class="sig-name descname"><span
56+
class="pre">demo</span></code>
57+
<a class="headerlink" href="#confval-some-other-demo"
58+
data-bs-toggle="modal"
59+
data-bs-target="#linkReferenceModal"
60+
data-id="confval-some-other-demo"
61+
data-rstCode=":ref:`demo &lt;somemanual:confval-some-other-demo&gt;`"
62+
title="Reference this configuration value"><i
63+
class="fa-solid fa-paragraph"></i></a>
64+
</div>
65+
<div class="confval-back-to-top"> <a href="#" class="backToTop" title="Back to top"><i
66+
class="fa-solid fa-arrow-up fa-xs"></i></a> </div>
67+
</dt>
68+
<dd>
69+
<dl class="field-list simple">
70+
<dt class="field-even">Type</dt>
71+
<dd class="field-even">string
72+
</dd>
73+
<dt class="field-odd">Default</dt>
74+
<dd class="field-odd"><code>&quot;Hello World&quot;</code>
75+
</dd>
76+
</dl>
77+
<div class="confval-description">
78+
79+
<p>Some Text</p>
80+
81+
</div>
82+
</dd>
83+
</dl>
84+
</section>
4685
</section>
4786
<!-- content end -->

tests/Integration/tests/confval/confval-basic/input/index.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,12 @@ Confval
1010
Some Text
1111

1212
See also :confval:`demo` or :ref:`demo <confval-demo>`.
13+
14+
15+
.. confval:: demo
16+
:name: Some_Other_Demo
17+
:type: string
18+
:default: ``"Hello World"``
19+
:required: False
20+
21+
Some Text

0 commit comments

Comments
 (0)