*/
final class EmphasisParser extends AbstractInlineTextDecoratorParser
@@ -39,7 +40,7 @@ protected function getType(): string
/** @param InlineNodeInterface[] $children */
protected function createInlineNode(CommonMarkNode $commonMarkNode, string|null $content, array $children = []): InlineNodeInterface
{
- return new EmphasisInlineNode($content ?? '', $children);
+ return new EmphasisInlineNode($content ? [new PlainTextInlineNode($content)] : $children);
}
protected function supportsCommonMarkNode(CommonMarkNode $commonMarkNode): bool
diff --git a/packages/guides-markdown/src/Markdown/Parsers/InlineParsers/LinkParser.php b/packages/guides-markdown/src/Markdown/Parsers/InlineParsers/LinkParser.php
index d4b640c9b..8b3c88a6a 100644
--- a/packages/guides-markdown/src/Markdown/Parsers/InlineParsers/LinkParser.php
+++ b/packages/guides-markdown/src/Markdown/Parsers/InlineParsers/LinkParser.php
@@ -20,6 +20,7 @@
use phpDocumentor\Guides\Nodes\Inline\InlineNodeInterface;
use Psr\Log\LoggerInterface;
+use phpDocumentor\Guides\Nodes\Inline\PlainTextInlineNode;
use function assert;
use function filter_var;
use function str_ends_with;
@@ -48,13 +49,12 @@ protected function createInlineNode(CommonMarkNode $commonMarkNode, string|null
{
assert($commonMarkNode instanceof Link);
- $content ??= $commonMarkNode->getUrl();
$url = $commonMarkNode->getUrl();
if (str_ends_with($url, '.md') && filter_var($url, FILTER_VALIDATE_URL) === false) {
$url = substr($url, 0, -3);
}
- return new HyperLinkNode($content, $url, $children);
+ return new HyperLinkNode($content ? [new PlainTextInlineNode($content)] : $children, $url);
}
protected function supportsCommonMarkNode(CommonMarkNode $commonMarkNode): bool
diff --git a/packages/guides-markdown/src/Markdown/Parsers/InlineParsers/StrongParser.php b/packages/guides-markdown/src/Markdown/Parsers/InlineParsers/StrongParser.php
index bb31d6175..f8cb0923b 100644
--- a/packages/guides-markdown/src/Markdown/Parsers/InlineParsers/StrongParser.php
+++ b/packages/guides-markdown/src/Markdown/Parsers/InlineParsers/StrongParser.php
@@ -17,6 +17,7 @@
use League\CommonMark\Node\Node as CommonMarkNode;
use phpDocumentor\Guides\Nodes\Inline\InlineNode;
use phpDocumentor\Guides\Nodes\Inline\InlineNodeInterface;
+use phpDocumentor\Guides\Nodes\Inline\PlainTextInlineNode;
use phpDocumentor\Guides\Nodes\Inline\StrongInlineNode;
use Psr\Log\LoggerInterface;
@@ -39,7 +40,7 @@ protected function getType(): string
/** @param InlineNodeInterface[] $children */
protected function createInlineNode(CommonMarkNode $commonMarkNode, string|null $content, array $children = []): InlineNodeInterface
{
- return new StrongInlineNode($content ?? '', $children);
+ return new StrongInlineNode($content ? [new PlainTextInlineNode($content)] : $children);
}
protected function supportsCommonMarkNode(CommonMarkNode $commonMarkNode): bool
diff --git a/packages/guides-restructured-text/src/RestructuredText/Directives/ImageDirective.php b/packages/guides-restructured-text/src/RestructuredText/Directives/ImageDirective.php
index 29730bad2..c1252a38d 100644
--- a/packages/guides-restructured-text/src/RestructuredText/Directives/ImageDirective.php
+++ b/packages/guides-restructured-text/src/RestructuredText/Directives/ImageDirective.php
@@ -77,21 +77,21 @@ public function processNode(
private function resolveLinkTarget(string $targetReference): LinkInlineNode
{
if (filter_var($targetReference, FILTER_VALIDATE_EMAIL)) {
- return new HyperLinkNode('', $targetReference);
+ return new HyperLinkNode([], $targetReference);
}
if (filter_var($targetReference, FILTER_VALIDATE_URL)) {
- return new HyperLinkNode('', $targetReference);
+ return new HyperLinkNode([], $targetReference);
}
if (preg_match(self::REFERENCE_REGEX, $targetReference, $matches)) {
- return new ReferenceNode($matches[1], '');
+ return new ReferenceNode($matches[1]);
}
if (preg_match(self::REFERENCE_ESCAPED_REGEX, $targetReference, $matches)) {
- return new ReferenceNode($matches[1], '');
+ return new ReferenceNode($matches[1]);
}
- return new DocReferenceNode($targetReference, '');
+ return new DocReferenceNode($targetReference);
}
}
diff --git a/packages/guides-restructured-text/src/RestructuredText/Parser/Productions/InlineRules/EmphasisRule.php b/packages/guides-restructured-text/src/RestructuredText/Parser/Productions/InlineRules/EmphasisRule.php
index b4c4e3545..f542831eb 100644
--- a/packages/guides-restructured-text/src/RestructuredText/Parser/Productions/InlineRules/EmphasisRule.php
+++ b/packages/guides-restructured-text/src/RestructuredText/Parser/Productions/InlineRules/EmphasisRule.php
@@ -15,6 +15,7 @@
use phpDocumentor\Guides\Nodes\Inline\EmphasisInlineNode;
use phpDocumentor\Guides\Nodes\Inline\InlineNodeInterface;
+use phpDocumentor\Guides\Nodes\Inline\PlainTextInlineNode;
use phpDocumentor\Guides\RestructuredText\Parser\BlockContext;
use phpDocumentor\Guides\RestructuredText\Parser\InlineLexer;
@@ -45,7 +46,7 @@ public function apply(BlockContext $blockContext, InlineLexer $lexer): InlineNod
$lexer->moveNext();
- return new EmphasisInlineNode($text);
+ return new EmphasisInlineNode([new PlainTextInlineNode($text)]);
default:
$text .= $token->value;
diff --git a/packages/guides-restructured-text/src/RestructuredText/Parser/Productions/InlineRules/ReferenceRule.php b/packages/guides-restructured-text/src/RestructuredText/Parser/Productions/InlineRules/ReferenceRule.php
index a395f5185..6412ed4ef 100644
--- a/packages/guides-restructured-text/src/RestructuredText/Parser/Productions/InlineRules/ReferenceRule.php
+++ b/packages/guides-restructured-text/src/RestructuredText/Parser/Productions/InlineRules/ReferenceRule.php
@@ -16,6 +16,7 @@
use phpDocumentor\Guides\Nodes\Inline\AbstractLinkInlineNode;
use phpDocumentor\Guides\Nodes\Inline\DocReferenceNode;
use phpDocumentor\Guides\Nodes\Inline\HyperLinkNode;
+use phpDocumentor\Guides\Nodes\Inline\PlainTextInlineNode;
use phpDocumentor\Guides\RestructuredText\Parser\BlockContext;
use function filter_var;
@@ -39,13 +40,17 @@ protected function createReference(BlockContext $blockContext, string $reference
if (str_ends_with($reference, '.rst') && filter_var($reference, FILTER_VALIDATE_URL) === false) {
$reference = substr($reference, 0, -4);
- return new DocReferenceNode($reference, $text ?? $reference);
+ $text ??= $reference;
+
+ return new DocReferenceNode($reference, $text !== '' ? [new PlainTextInlineNode($text)] : []);
}
if ($registerLink && $text !== null) {
$blockContext->getDocumentParserContext()->setLink($text, $reference);
}
- return new HyperLinkNode($text ?? $reference, $reference);
+ $text ??= $reference;
+
+ return new HyperLinkNode($text !== '' ? [new PlainTextInlineNode($text)] : [], $reference);
}
}
diff --git a/packages/guides-restructured-text/src/RestructuredText/Parser/Productions/InlineRules/StrongRule.php b/packages/guides-restructured-text/src/RestructuredText/Parser/Productions/InlineRules/StrongRule.php
index b9475a104..ae102aefe 100644
--- a/packages/guides-restructured-text/src/RestructuredText/Parser/Productions/InlineRules/StrongRule.php
+++ b/packages/guides-restructured-text/src/RestructuredText/Parser/Productions/InlineRules/StrongRule.php
@@ -14,6 +14,7 @@
namespace phpDocumentor\Guides\RestructuredText\Parser\Productions\InlineRules;
use phpDocumentor\Guides\Nodes\Inline\InlineNodeInterface;
+use phpDocumentor\Guides\Nodes\Inline\PlainTextInlineNode;
use phpDocumentor\Guides\Nodes\Inline\StrongInlineNode;
use phpDocumentor\Guides\RestructuredText\Parser\BlockContext;
use phpDocumentor\Guides\RestructuredText\Parser\InlineLexer;
@@ -45,7 +46,7 @@ public function apply(BlockContext $blockContext, InlineLexer $lexer): InlineNod
$lexer->moveNext();
- return new StrongInlineNode($text);
+ return new StrongInlineNode([new PlainTextInlineNode($text)]);
default:
$text .= $token->value;
diff --git a/packages/guides-restructured-text/src/RestructuredText/TextRoles/ApiClassTextRole.php b/packages/guides-restructured-text/src/RestructuredText/TextRoles/ApiClassTextRole.php
index fcb348e9d..8243cc6bd 100644
--- a/packages/guides-restructured-text/src/RestructuredText/TextRoles/ApiClassTextRole.php
+++ b/packages/guides-restructured-text/src/RestructuredText/TextRoles/ApiClassTextRole.php
@@ -14,6 +14,7 @@
namespace phpDocumentor\Guides\RestructuredText\TextRoles;
use phpDocumentor\Guides\Nodes\Inline\AbstractLinkInlineNode;
+use phpDocumentor\Guides\Nodes\Inline\PlainTextInlineNode;
use phpDocumentor\Guides\Nodes\Inline\ReferenceNode;
use phpDocumentor\Guides\ReferenceResolvers\AnchorNormalizer;
use phpDocumentor\Guides\RestructuredText\Parser\Interlink\InterlinkParser;
@@ -49,6 +50,6 @@ protected function createNode(string $referenceTarget, string|null $referenceNam
$reference = $this->anchorReducer->reduceAnchor($interlinkData->reference);
$prefix = $this->genericLinkProvider->getLinkPrefix($role);
- return new ReferenceNode($reference, $referenceName ?? '', $interlinkData->interlink, self::TYPE, $prefix);
+ return new ReferenceNode($reference, $referenceName ? [new PlainTextInlineNode($referenceName)] : [], $interlinkData->interlink, self::TYPE, $prefix);
}
}
diff --git a/packages/guides-restructured-text/src/RestructuredText/TextRoles/DocReferenceTextRole.php b/packages/guides-restructured-text/src/RestructuredText/TextRoles/DocReferenceTextRole.php
index 7c0370d06..3d028b920 100644
--- a/packages/guides-restructured-text/src/RestructuredText/TextRoles/DocReferenceTextRole.php
+++ b/packages/guides-restructured-text/src/RestructuredText/TextRoles/DocReferenceTextRole.php
@@ -15,6 +15,7 @@
use phpDocumentor\Guides\Nodes\Inline\AbstractLinkInlineNode;
use phpDocumentor\Guides\Nodes\Inline\DocReferenceNode;
+use phpDocumentor\Guides\Nodes\Inline\PlainTextInlineNode;
use phpDocumentor\Guides\RestructuredText\Parser\Interlink\InterlinkParser;
/**
@@ -51,6 +52,6 @@ protected function createNode(string $referenceTarget, string|null $referenceNam
{
$interlinkData = $this->interlinkParser->extractInterlink($referenceTarget);
- return new DocReferenceNode($interlinkData->reference, $referenceName ?? '', $interlinkData->interlink);
+ return new DocReferenceNode($interlinkData->reference, $referenceName ? [new PlainTextInlineNode($referenceName)] : [], $interlinkData->interlink);
}
}
diff --git a/packages/guides-restructured-text/src/RestructuredText/TextRoles/GenericReferenceTextRole.php b/packages/guides-restructured-text/src/RestructuredText/TextRoles/GenericReferenceTextRole.php
index 04e32bfc9..64ef0a625 100644
--- a/packages/guides-restructured-text/src/RestructuredText/TextRoles/GenericReferenceTextRole.php
+++ b/packages/guides-restructured-text/src/RestructuredText/TextRoles/GenericReferenceTextRole.php
@@ -14,6 +14,7 @@
namespace phpDocumentor\Guides\RestructuredText\TextRoles;
use phpDocumentor\Guides\Nodes\Inline\AbstractLinkInlineNode;
+use phpDocumentor\Guides\Nodes\Inline\PlainTextInlineNode;
use phpDocumentor\Guides\Nodes\Inline\ReferenceNode;
use phpDocumentor\Guides\ReferenceResolvers\AnchorNormalizer;
use phpDocumentor\Guides\RestructuredText\Parser\Interlink\InterlinkParser;
@@ -48,6 +49,12 @@ protected function createNode(string $referenceTarget, string|null $referenceNam
$reference = $this->anchorReducer->reduceAnchor($interlinkData->reference);
$prefix = $this->genericLinkProvider->getLinkPrefix($role);
- return new ReferenceNode($reference, $referenceName ?? '', $interlinkData->interlink, $linkType, $prefix);
+ return new ReferenceNode(
+ $reference,
+ $referenceName ? [new PlainTextInlineNode($referenceName)] : [],
+ $interlinkData->interlink,
+ $linkType,
+ $prefix
+ );
}
}
diff --git a/packages/guides-restructured-text/src/RestructuredText/TextRoles/ReferenceTextRole.php b/packages/guides-restructured-text/src/RestructuredText/TextRoles/ReferenceTextRole.php
index 7d76d324e..171d5dd7b 100644
--- a/packages/guides-restructured-text/src/RestructuredText/TextRoles/ReferenceTextRole.php
+++ b/packages/guides-restructured-text/src/RestructuredText/TextRoles/ReferenceTextRole.php
@@ -14,6 +14,7 @@
namespace phpDocumentor\Guides\RestructuredText\TextRoles;
use phpDocumentor\Guides\Nodes\Inline\AbstractLinkInlineNode;
+use phpDocumentor\Guides\Nodes\Inline\PlainTextInlineNode;
use phpDocumentor\Guides\Nodes\Inline\ReferenceNode;
final class ReferenceTextRole extends AbstractReferenceTextRole
@@ -34,6 +35,6 @@ public function getAliases(): array
/** @return ReferenceNode */
protected function createNode(string $referenceTarget, string|null $referenceName, string $role): AbstractLinkInlineNode
{
- return new ReferenceNode($referenceTarget, $referenceName ?? '');
+ return new ReferenceNode($referenceTarget, $referenceName ? [new PlainTextInlineNode($referenceName)] : []);
}
}
diff --git a/packages/guides-theme-rst/resources/template/rst/inline/emphasis.rst.twig b/packages/guides-theme-rst/resources/template/rst/inline/emphasis.rst.twig
index 7c0eee195..1c35549ab 100644
--- a/packages/guides-theme-rst/resources/template/rst/inline/emphasis.rst.twig
+++ b/packages/guides-theme-rst/resources/template/rst/inline/emphasis.rst.twig
@@ -1 +1 @@
-*{{- node.value|raw -}}*
+*{{- node|plaintext -}}*
diff --git a/packages/guides-theme-rst/resources/template/rst/inline/link.rst.twig b/packages/guides-theme-rst/resources/template/rst/inline/link.rst.twig
index edde6ce9c..572b26fea 100644
--- a/packages/guides-theme-rst/resources/template/rst/inline/link.rst.twig
+++ b/packages/guides-theme-rst/resources/template/rst/inline/link.rst.twig
@@ -1,7 +1,7 @@
{%- if node.url -%}
- `{{ node.value|raw }} <{{- node.url -}}>`__
+ `{{ node|plaintext }} <{{- node.url -}}>`__
{%- elseif node.targetReference -%}
- :doc:`{{ node.value|raw }} <{{- node.targetReference -}}>`
+ :doc:`{{ node|plaintext }} <{{- node.targetReference -}}>`
{%- else -%}
- {{- node.value -}}
+ {{- node|plaintext -}}
{%- endif -%}
diff --git a/packages/guides-theme-rst/resources/template/rst/inline/strong.rst.twig b/packages/guides-theme-rst/resources/template/rst/inline/strong.rst.twig
index 3a08cb2cc..52ff83d17 100644
--- a/packages/guides-theme-rst/resources/template/rst/inline/strong.rst.twig
+++ b/packages/guides-theme-rst/resources/template/rst/inline/strong.rst.twig
@@ -1 +1 @@
-**{{- node.value|raw -}}**
+**{{- node|plaintext -}}**
diff --git a/packages/guides-theme-rst/src/RstTheme/Twig/RstExtension.php b/packages/guides-theme-rst/src/RstTheme/Twig/RstExtension.php
index c0b697f29..2438ff14b 100644
--- a/packages/guides-theme-rst/src/RstTheme/Twig/RstExtension.php
+++ b/packages/guides-theme-rst/src/RstTheme/Twig/RstExtension.php
@@ -14,6 +14,8 @@
namespace phpDocumentor\Guides\RstTheme\Twig;
use phpDocumentor\Guides\NodeRenderers\NodeRenderer;
+use phpDocumentor\Guides\Nodes\Inline\InlineNodeInterface;
+use phpDocumentor\Guides\Nodes\InlineCompoundNode;
use phpDocumentor\Guides\Nodes\Table\TableColumn;
use phpDocumentor\Guides\Nodes\Table\TableRow;
use phpDocumentor\Guides\Nodes\TableNode;
@@ -57,14 +59,24 @@ public function getFunctions(): array
public function getFilters(): array
{
return [
- new TwigFilter('clean_content', [$this, 'cleanContent']),
+ new TwigFilter('clean_content', $this->cleanContent(...)),
+ new TwigFilter('plaintext', $this->plaintext(...)),
];
}
+ public function plaintext(InlineNodeInterface $node): string
+ {
+ if ($node instanceof InlineCompoundNode) {
+ return implode('', array_map($this->plaintext(...), $node->getChildren()));
+ }
+
+ return $node->toString();
+ }
+
public function cleanContent(string $content): string
{
$lines = explode("\n", $content);
- $lines = array_map('rtrim', $lines);
+ $lines = array_map(rtrim(...), $lines);
$content = implode("\n", $lines);
$content = preg_replace('/(\n){2,}/', "\n\n", $content);
diff --git a/packages/guides/src/Nodes/Inline/AbstractLinkInlineNode.php b/packages/guides/src/Nodes/Inline/AbstractLinkInlineNode.php
index 893061bd6..b00439ba1 100644
--- a/packages/guides/src/Nodes/Inline/AbstractLinkInlineNode.php
+++ b/packages/guides/src/Nodes/Inline/AbstractLinkInlineNode.php
@@ -74,7 +74,7 @@ public function getDebugInformation(): array
return [
'type' => $this->getType(),
'targetReference' => $this->getTargetReference(),
- 'value' => $this->getValue(),
+ 'value' => $this->toString(),
];
}
diff --git a/packages/guides/src/ReferenceResolvers/AnchorHyperlinkResolver.php b/packages/guides/src/ReferenceResolvers/AnchorHyperlinkResolver.php
index ed8757d31..52e0e27dc 100644
--- a/packages/guides/src/ReferenceResolvers/AnchorHyperlinkResolver.php
+++ b/packages/guides/src/ReferenceResolvers/AnchorHyperlinkResolver.php
@@ -15,10 +15,13 @@
use phpDocumentor\Guides\Nodes\Inline\HyperLinkNode;
use phpDocumentor\Guides\Nodes\Inline\LinkInlineNode;
+use phpDocumentor\Guides\Nodes\Inline\PlainTextInlineNode;
use phpDocumentor\Guides\Nodes\SectionNode;
use phpDocumentor\Guides\RenderContext;
use phpDocumentor\Guides\Renderer\UrlGenerator\UrlGeneratorInterface;
+use function count;
+
/**
* Resolves references with an anchor URL.
*
@@ -51,8 +54,8 @@ public function resolve(LinkInlineNode $node, RenderContext $renderContext, Mess
}
$node->setUrl($this->urlGenerator->generateCanonicalOutputUrl($renderContext, $target->getDocumentPath(), $target->getAnchor()));
- if ($node->getValue() === '') {
- $node->setValue($target->getTitle() ?? '');
+ if (count($node->getChildren()) === 0) {
+ $node->addChildNode(new PlainTextInlineNode($target->getTitle() ?? ''));
}
return true;
diff --git a/packages/guides/src/ReferenceResolvers/AnchorReferenceResolver.php b/packages/guides/src/ReferenceResolvers/AnchorReferenceResolver.php
index 4bead238f..c1ba64412 100644
--- a/packages/guides/src/ReferenceResolvers/AnchorReferenceResolver.php
+++ b/packages/guides/src/ReferenceResolvers/AnchorReferenceResolver.php
@@ -14,10 +14,13 @@
namespace phpDocumentor\Guides\ReferenceResolvers;
use phpDocumentor\Guides\Nodes\Inline\LinkInlineNode;
+use phpDocumentor\Guides\Nodes\Inline\PlainTextInlineNode;
use phpDocumentor\Guides\Nodes\Inline\ReferenceNode;
use phpDocumentor\Guides\RenderContext;
use phpDocumentor\Guides\Renderer\UrlGenerator\UrlGeneratorInterface;
+use function count;
+
/**
* Resolves references with an anchor URL.
*
@@ -47,8 +50,8 @@ public function resolve(LinkInlineNode $node, RenderContext $renderContext, Mess
}
$node->setUrl($this->urlGenerator->generateCanonicalOutputUrl($renderContext, $target->getDocumentPath(), $target->getPrefix() . $target->getAnchor()));
- if ($node->getValue() === '') {
- $node->setValue($target->getTitle() ?? '');
+ if (count($node->getChildren()) === 0) {
+ $node->addChildNode(new PlainTextInlineNode($target->getTitle() ?? ''));
}
return true;
diff --git a/packages/guides/src/ReferenceResolvers/DocReferenceResolver.php b/packages/guides/src/ReferenceResolvers/DocReferenceResolver.php
index 0de9e76b8..33a3b51f3 100644
--- a/packages/guides/src/ReferenceResolvers/DocReferenceResolver.php
+++ b/packages/guides/src/ReferenceResolvers/DocReferenceResolver.php
@@ -15,9 +15,11 @@
use phpDocumentor\Guides\Nodes\Inline\DocReferenceNode;
use phpDocumentor\Guides\Nodes\Inline\LinkInlineNode;
+use phpDocumentor\Guides\Nodes\Inline\PlainTextInlineNode;
use phpDocumentor\Guides\RenderContext;
use phpDocumentor\Guides\Renderer\UrlGenerator\UrlGeneratorInterface;
+use function count;
use function explode;
use function sprintf;
use function str_contains;
@@ -64,8 +66,8 @@ public function resolve(LinkInlineNode $node, RenderContext $renderContext, Mess
}
$node->setUrl($this->urlGenerator->generateCanonicalOutputUrl($renderContext, $document->getFile()) . $anchor);
- if ($node->getValue() === '') {
- $node->setValue($document->getTitle()->toString());
+ if (count($node->getChildren()) === 0) {
+ $node->addChildNode(new PlainTextInlineNode($document->getTitle()->toString()));
}
return true;
diff --git a/packages/guides/src/ReferenceResolvers/InterlinkReferenceResolver.php b/packages/guides/src/ReferenceResolvers/InterlinkReferenceResolver.php
index 2ac497d1d..f9e19c289 100644
--- a/packages/guides/src/ReferenceResolvers/InterlinkReferenceResolver.php
+++ b/packages/guides/src/ReferenceResolvers/InterlinkReferenceResolver.php
@@ -15,9 +15,12 @@
use phpDocumentor\Guides\Nodes\Inline\CrossReferenceNode;
use phpDocumentor\Guides\Nodes\Inline\LinkInlineNode;
+use phpDocumentor\Guides\Nodes\Inline\PlainTextInlineNode;
use phpDocumentor\Guides\ReferenceResolvers\Interlink\InventoryRepository;
use phpDocumentor\Guides\RenderContext;
+use function count;
+
final class InterlinkReferenceResolver implements ReferenceResolver
{
public final const PRIORITY = 50;
@@ -44,8 +47,8 @@ public function resolve(LinkInlineNode $node, RenderContext $renderContext, Mess
}
$node->setUrl($inventory->getBaseUrl() . $link->getPath());
- if ($node->getValue() === '') {
- $node->setValue($link->getTitle());
+ if (count($node->getChildren()) === 0) {
+ $node->addChildNode(new PlainTextInlineNode($link->getTitle()));
}
return true;
diff --git a/packages/guides/src/ReferenceResolvers/PageHyperlinkResolver.php b/packages/guides/src/ReferenceResolvers/PageHyperlinkResolver.php
index a4fd7f4c9..b0d97b7ec 100644
--- a/packages/guides/src/ReferenceResolvers/PageHyperlinkResolver.php
+++ b/packages/guides/src/ReferenceResolvers/PageHyperlinkResolver.php
@@ -18,6 +18,7 @@
use phpDocumentor\Guides\RenderContext;
use phpDocumentor\Guides\Renderer\UrlGenerator\UrlGeneratorInterface;
+use function count;
use function str_ends_with;
use function strlen;
use function substr;
@@ -55,8 +56,8 @@ public function resolve(LinkInlineNode $node, RenderContext $renderContext, Mess
}
$node->setUrl($this->urlGenerator->generateCanonicalOutputUrl($renderContext, $document->getFile()));
- if ($node->getValue() === '') {
- $node->setValue($document->getTitle()->toString());
+ if (count($node->getChildren()) === 0) {
+ $node->addChildNode(new PlainTextInlineNode($document->getTitle()->toString()));
}
return true;
diff --git a/packages/guides/src/ReferenceResolvers/TitleReferenceResolver.php b/packages/guides/src/ReferenceResolvers/TitleReferenceResolver.php
index 05e5d7282..b983fbcfb 100644
--- a/packages/guides/src/ReferenceResolvers/TitleReferenceResolver.php
+++ b/packages/guides/src/ReferenceResolvers/TitleReferenceResolver.php
@@ -14,11 +14,14 @@
namespace phpDocumentor\Guides\ReferenceResolvers;
use phpDocumentor\Guides\Nodes\Inline\LinkInlineNode;
+use phpDocumentor\Guides\Nodes\Inline\PlainTextInlineNode;
use phpDocumentor\Guides\Nodes\Inline\ReferenceNode;
use phpDocumentor\Guides\Nodes\SectionNode;
use phpDocumentor\Guides\RenderContext;
use phpDocumentor\Guides\Renderer\UrlGenerator\UrlGeneratorInterface;
+use function count;
+
/**
* Resolves references with an anchor URL.
*
@@ -48,8 +51,8 @@ public function resolve(LinkInlineNode $node, RenderContext $renderContext, Mess
}
$node->setUrl($this->urlGenerator->generateCanonicalOutputUrl($renderContext, $target->getDocumentPath(), $target->getPrefix() . $target->getAnchor()));
- if ($node->getValue() === '') {
- $node->setValue($target->getTitle() ?? '');
+ if (count($node->getChildren()) === 0) {
+ $node->addChildNode(new PlainTextInlineNode($target->getTitle() ?? ''));
}
return true;
diff --git a/packages/guides/tests/unit/Compiler/CompilerContextTest.php b/packages/guides/tests/unit/Compiler/CompilerContextTest.php
index 075bee7a0..5991fb78f 100644
--- a/packages/guides/tests/unit/Compiler/CompilerContextTest.php
+++ b/packages/guides/tests/unit/Compiler/CompilerContextTest.php
@@ -14,6 +14,7 @@
namespace phpDocumentor\Guides\Compiler;
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
+use PHPUnit\Framework\Attributes\WithoutErrorHandler;
use phpDocumentor\Guides\Nodes\ProjectNode;
use PHPUnit\Framework\TestCase;
@@ -21,6 +22,7 @@ final class CompilerContextTest extends TestCase
{
use VerifyDeprecations;
+ #[WithoutErrorHandler]
public function testTriggersDeprecationOnContextExtend(): void
{
$this->expectDeprecationWithIdentifier('https://github.com/phpDocumentor/guides/issues/971');
@@ -28,6 +30,7 @@ public function testTriggersDeprecationOnContextExtend(): void
};
}
+ #[WithoutErrorHandler]
public function testNoDeprecationOnNormalConstruct(): void
{
$this->expectNoDeprecationWithIdentifier('https://github.com/phpDocumentor/guides/issues/971');
diff --git a/packages/guides/tests/unit/Interlink/InventoryGroupTest.php b/packages/guides/tests/unit/Interlink/InventoryGroupTest.php
index 371cbebf2..3c4c4be10 100644
--- a/packages/guides/tests/unit/Interlink/InventoryGroupTest.php
+++ b/packages/guides/tests/unit/Interlink/InventoryGroupTest.php
@@ -41,7 +41,7 @@ public function testGetLinkFromInterlinkGroup(string $expected, string $input, s
$this->inventoryGroup->addLink($path, new InventoryLink('', '', $path . '.html', ''));
$messages = new Messages();
$link = $this->inventoryGroup->getLink(
- new DocReferenceNode($input, '', 'interlink'),
+ new DocReferenceNode($input, [], 'interlink'),
$this->renderContext,
$messages,
);
diff --git a/packages/guides/tests/unit/Interlink/InventoryLoaderTest.php b/packages/guides/tests/unit/Interlink/InventoryLoaderTest.php
index 1e476a976..b60e516b0 100644
--- a/packages/guides/tests/unit/Interlink/InventoryLoaderTest.php
+++ b/packages/guides/tests/unit/Interlink/InventoryLoaderTest.php
@@ -74,7 +74,7 @@ public function loadObjectsJsonInv(string $filename): void
public function testInventoryLoaderLoadsInventory(): void
{
- $node = new DocReferenceNode('SomeDocument', '', 'somekey');
+ $node = new DocReferenceNode('SomeDocument', [], 'somekey');
$inventory = $this->inventoryRepository->getInventory($node, $this->renderContext, new Messages());
self::assertTrue($inventory instanceof Inventory);
self::assertGreaterThan(1, count($inventory->getGroups()));
@@ -92,7 +92,7 @@ public function testInventoryIsLoadedExactlyOnce(): void
public function testInventoryLoaderAcceptsNull(): void
{
$this->loadObjectsJsonInv(__DIR__ . '/fixtures/null-in-objects.inv.json');
- $node = new DocReferenceNode('SomeDocument', '', 'somekey');
+ $node = new DocReferenceNode('SomeDocument', [], 'somekey');
$inventory = $this->inventoryRepository->getInventory($node, $this->renderContext, new Messages());
self::assertTrue($inventory instanceof Inventory);
self::assertGreaterThan(1, count($inventory->getGroups()));
@@ -111,47 +111,47 @@ public static function rawAnchorProvider(): Generator
{
yield 'Simple label' => [
'some_page.html#modindex',
- new ReferenceNode('modindex', '', 'somekey'),
+ new ReferenceNode('modindex', [], 'somekey'),
];
yield 'Inventory with changed case' => [
'some_page.html#modindex',
- new ReferenceNode('modindex', '', 'SomeKey'),
+ new ReferenceNode('modindex', [], 'SomeKey'),
];
yield 'Inventory with minus' => [
'some_page.html#modindex',
- new ReferenceNode('modindex', '', 'some-key'),
+ new ReferenceNode('modindex', [], 'some-key'),
];
yield 'Inventory with underscore and changed case' => [
'some_page.html#modindex',
- new ReferenceNode('modindex', '', 'Some_Key'),
+ new ReferenceNode('modindex', [], 'Some_Key'),
];
yield 'Both with minus' => [
'some_page.html#php-modindex',
- new ReferenceNode('php-modindex', '', 'somekey'),
+ new ReferenceNode('php-modindex', [], 'somekey'),
];
yield 'Linked with underscore, inventory with minus' => [
'some_page.html#php-modindex',
- new ReferenceNode('php_modindex', '', 'somekey'),
+ new ReferenceNode('php_modindex', [], 'somekey'),
];
yield 'Linked with underscore, inventory with underscore' => [
'php-objectsindex.html#php-objectsindex',
- new ReferenceNode('php_objectsindex', '', 'somekey'),
+ new ReferenceNode('php_objectsindex', [], 'somekey'),
];
yield 'Linked with minus, inventory with underscore' => [
'php-objectsindex.html#php-objectsindex',
- new ReferenceNode('php-objectsindex', '', 'somekey'),
+ new ReferenceNode('php-objectsindex', [], 'somekey'),
];
yield 'Doc link' => [
'Page1/Subpage1.html',
- new DocReferenceNode('Page1/Subpage1', '', 'somekey'),
+ new DocReferenceNode('Page1/Subpage1', [], 'somekey'),
];
}
@@ -167,15 +167,15 @@ public function testInventoryLinkNotFound(CrossReferenceNode $node): void
public static function notFoundInventoryProvider(): Generator
{
yield 'Simple labe not found' => [
- new ReferenceNode('non-existant-label', '', 'somekey'),
+ new ReferenceNode('non-existant-label', [], 'somekey'),
];
yield 'docs are casesensitve' => [
- new DocReferenceNode('index', '', 'somekey'),
+ new DocReferenceNode('index', [], 'somekey'),
];
yield 'docs are not slugged' => [
- new DocReferenceNode('Page1-Subpage1', '', 'somekey'),
+ new DocReferenceNode('Page1-Subpage1', [], 'somekey'),
];
}
}
diff --git a/packages/guides/tests/unit/ReferenceResolvers/InterlinkReferenceResolverTest.php b/packages/guides/tests/unit/ReferenceResolvers/InterlinkReferenceResolverTest.php
index 60e16547b..fe256b252 100644
--- a/packages/guides/tests/unit/ReferenceResolvers/InterlinkReferenceResolverTest.php
+++ b/packages/guides/tests/unit/ReferenceResolvers/InterlinkReferenceResolverTest.php
@@ -40,7 +40,7 @@ protected function setUp(): void
#[DataProvider('pathProvider')]
public function testDocumentReducer(string $expected, string $input, string $path): void
{
- $input = new DocReferenceNode($input, '', 'interlink-target');
+ $input = new DocReferenceNode($input, [], 'interlink-target');
$inventoryLink = new InventoryLink('project', '1.0', $path, '');
$inventory = new Inventory('base-url/', $this->anchorNormalizer);
$this->inventoryRepository->expects(self::once())->method('getInventory')->willReturn($inventory);
diff --git a/tests/Integration/tests/graphs/plantuml-external/expected/Plantuml/index.html b/tests/Integration/tests/graphs/plantuml-external/expected/Plantuml/index.html
index 1a93dce09..720fb1dac 100644
--- a/tests/Integration/tests/graphs/plantuml-external/expected/Plantuml/index.html
+++ b/tests/Integration/tests/graphs/plantuml-external/expected/Plantuml/index.html
@@ -1,15 +1,13 @@
-
Uml Directive
-
-
+ Uml Directive
+
+
diff --git a/tests/Integration/tests/graphs/plantuml-external/expected/index.html b/tests/Integration/tests/graphs/plantuml-external/expected/index.html
index a731f116f..047febb17 100644
--- a/tests/Integration/tests/graphs/plantuml-external/expected/index.html
+++ b/tests/Integration/tests/graphs/plantuml-external/expected/index.html
@@ -1,24 +1,20 @@
Uml Directive
-
-
+
+
-
-
+
+
diff --git a/tests/Integration/tests/graphs/plantuml-inline/expected/index.html b/tests/Integration/tests/graphs/plantuml-inline/expected/index.html
index c886287ba..c9e999ac2 100644
--- a/tests/Integration/tests/graphs/plantuml-inline/expected/index.html
+++ b/tests/Integration/tests/graphs/plantuml-inline/expected/index.html
@@ -1,15 +1,12 @@
Uml Directive
-
-
+
+
diff --git a/tests/Integration/tests/graphs/plantuml-server-error/expected/index.html b/tests/Integration/tests/graphs/plantuml-server-error/expected/index.html
index 2f55a1bda..b906f3bb4 100644
--- a/tests/Integration/tests/graphs/plantuml-server-error/expected/index.html
+++ b/tests/Integration/tests/graphs/plantuml-server-error/expected/index.html
@@ -1,11 +1,11 @@
Uml Directive
-
-
+
+