Skip to content

Commit

Permalink
[BUGFIX] Normalize Anchors in Permalink dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
linawolf committed Dec 3, 2024
1 parent 268920e commit d438840
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 3 deletions.
1 change: 1 addition & 0 deletions Documentation-rendertest/Admonitions-and-buttons/Index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.. include:: /Includes.rst.txt

.. _Adminitions_And_Buttons:

=======================
Admonitions and buttons
Expand Down
4 changes: 3 additions & 1 deletion packages/typo3-docs-theme/src/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use phpDocumentor\Guides\Nodes\Node;
use phpDocumentor\Guides\Nodes\PrefixedLinkTargetNode;
use phpDocumentor\Guides\Nodes\SectionNode;
use phpDocumentor\Guides\ReferenceResolvers\AnchorNormalizer;
use phpDocumentor\Guides\ReferenceResolvers\DocumentNameResolverInterface;
use phpDocumentor\Guides\RenderContext;
use phpDocumentor\Guides\Renderer\UrlGenerator\UrlGeneratorInterface;
Expand Down Expand Up @@ -60,6 +61,7 @@ public function __construct(
private readonly Typo3DocsThemeSettings $themeSettings,
private readonly DocumentNameResolverInterface $documentNameResolver,
private readonly Typo3VersionService $typo3VersionService,
private readonly AnchorNormalizer $anchorNormalizer,
) {
if (strlen((string)getenv('GITHUB_ACTIONS')) > 0 && strlen((string)getenv('TYPO3AZUREEDGEURIVERSION')) > 0 && !isset($_ENV['CI_PHPUNIT'])) {
// CI gets special treatment, then we use a fixed URI for assets.
Expand Down Expand Up @@ -255,7 +257,7 @@ public function getAnchorIdOfSection(array $context, SectionNode $sectionNode):
{
foreach ($sectionNode->getChildren() as $childNode) {
if ($childNode instanceof AnchorNode) {
return $childNode->toString();
return $this->anchorNormalizer->reduceAnchor($childNode->toString());
}
}
return '';
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/tests-full/link-wizard/expected/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@
<article class="document" itemscope="itemscope" itemtype="http://schema.org/Article" role="main">
<div itemprop="articleBody">
<!-- content start -->
<section class="section" id="document-title" data-rst-anchor="my_document">
<section class="section" id="document-title" data-rst-anchor="my-document">
<a id="my_document"></a>
<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>

<p>Lorem Ipsum Dolor.</p>

<section class="section" id="section-1" data-rst-anchor="my_section">
<section class="section" id="section-1" data-rst-anchor="my-section">
<a id="my_section"></a>
<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>
</section>
Expand Down
39 changes: 39 additions & 0 deletions tests/Integration/tests/confval/confval-basic/expected/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,44 @@ <h3 class="sr-only">demo</h3>

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

<section data-search-title="demo"
data-search-id="confval-some-other-demo"
data-search-facet="Option"
class="confval-section"
>
<h3 class="sr-only">demo</h3>
<dl class="confval">
<dt id="confval-some-other-demo" class="d-flex justify-content-between">
<div class="confval-header">
<code class="sig-name descname"><span
class="pre">demo</span></code>
<a class="headerlink" href="#confval-some-other-demo"
data-bs-toggle="modal"
data-bs-target="#linkReferenceModal"
data-id="confval-some-other-demo"
data-rstCode=":ref:`demo &lt;somemanual:confval-some-other-demo&gt;`"
title="Reference this configuration value"><i
class="fa-solid fa-paragraph"></i></a>
</div>
<div class="confval-back-to-top"> <a href="#" class="backToTop" title="Back to top"><i
class="fa-solid fa-arrow-up fa-xs"></i></a> </div>
</dt>
<dd>
<dl class="field-list simple">
<dt class="field-even">Type</dt>
<dd class="field-even">string
</dd>
<dt class="field-odd">Default</dt>
<dd class="field-odd"><code>&quot;Hello World&quot;</code>
</dd>
</dl>
<div class="confval-description">

<p>Some Text</p>

</div>
</dd>
</dl>
</section>
</section>
<!-- content end -->
9 changes: 9 additions & 0 deletions tests/Integration/tests/confval/confval-basic/input/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ Confval
Some Text

See also :confval:`demo` or :ref:`demo <confval-demo>`.


.. confval:: demo
:name: Some_Other_Demo
:type: string
:default: ``"Hello World"``
:required: False

Some Text

0 comments on commit d438840

Please sign in to comment.