Skip to content

Commit 67478e4

Browse files
committed
[BUGFIX] Preserve backslashes in php textrole
Resolves #244
1 parent 10301a4 commit 67478e4

File tree

6 files changed

+42
-0
lines changed

6 files changed

+42
-0
lines changed

packages/typo3-docs-theme/resources/config/typo3-docs-theme.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use T3Docs\Typo3DocsTheme\Directives\YoutubeDirective;
1818
use T3Docs\Typo3DocsTheme\Inventory\Typo3InventoryRepository;
1919
use T3Docs\Typo3DocsTheme\TextRoles\IssueReferenceTextRole;
20+
use T3Docs\Typo3DocsTheme\TextRoles\PhpTextRole;
2021
use T3Docs\Typo3DocsTheme\Twig\TwigExtension;
2122

2223
use function Symfony\Component\DependencyInjection\Loader\Configurator\param;
@@ -36,6 +37,8 @@
3637
->autowire()
3738
->set(IssueReferenceTextRole::class)
3839
->tag('phpdoc.guides.parser.rst.text_role')
40+
->set(PhpTextRole::class)
41+
->tag('phpdoc.guides.parser.rst.text_role')
3942

4043
->set(GroupTabDirective::class)
4144
->set(T3FieldListTableDirective::class)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace T3Docs\Typo3DocsTheme\TextRoles;
4+
5+
use phpDocumentor\Guides\Nodes\Inline\GenericTextRoleInlineNode;
6+
use phpDocumentor\Guides\Nodes\Inline\InlineNode;
7+
use phpDocumentor\Guides\RestructuredText\Parser\DocumentParserContext;
8+
use phpDocumentor\Guides\RestructuredText\TextRoles\TextRole;
9+
10+
final class PhpTextRole implements TextRole
11+
{
12+
public function getName(): string
13+
{
14+
return 'php';
15+
}
16+
17+
public function getAliases(): array
18+
{
19+
return [];
20+
}
21+
22+
public function processNode(DocumentParserContext $documentParserContext, string $role, string $content, string $rawContent): InlineNode
23+
{
24+
return new GenericTextRoleInlineNode('literal', $rawContent, 'php');
25+
}
26+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- content start -->
2+
<section class="section" id="php-code">
3+
<h1>PHP Code<a class="headerlink" href="#php-code" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
4+
5+
<p><code class="code-inline php" translate="no">\T3Docs\Typo3DocsTheme\TextRoles\PhpTextRole</code>.</p>
6+
</section>
7+
8+
<!-- content end -->
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
========
2+
PHP Code
3+
========
4+
5+
:php:`\T3Docs\Typo3DocsTheme\TextRoles\PhpTextRole`.

0 commit comments

Comments
 (0)