diff --git a/packages/guides-markdown/src/Markdown/Parsers/InlineParsers/InlineImageParser.php b/packages/guides-markdown/src/Markdown/Parsers/InlineParsers/InlineImageParser.php index 94acaa875..cc1815454 100644 --- a/packages/guides-markdown/src/Markdown/Parsers/InlineParsers/InlineImageParser.php +++ b/packages/guides-markdown/src/Markdown/Parsers/InlineParsers/InlineImageParser.php @@ -52,7 +52,7 @@ protected function createInlineNode(CommonMarkNode $commonMarkNode, string|null ); } - return new ImageInlineNode($commonMarkNode->getUrl(), $content ?? ''); + return new ImageInlineNode($commonMarkNode->getUrl(), $content ?? '', $commonMarkNode->getTitle() ?? ''); } protected function supportsCommonMarkNode(CommonMarkNode $commonMarkNode): bool diff --git a/packages/guides/resources/template/html/inline/image.html.twig b/packages/guides/resources/template/html/inline/image.html.twig index b933435b4..3da6db2e0 100644 --- a/packages/guides/resources/template/html/inline/image.html.twig +++ b/packages/guides/resources/template/html/inline/image.html.twig @@ -1 +1,2 @@ -{{- node.altText -}} +{{- node.altText -}} diff --git a/packages/guides/src/Nodes/Inline/ImageInlineNode.php b/packages/guides/src/Nodes/Inline/ImageInlineNode.php index ffd0c7838..e44550bb9 100644 --- a/packages/guides/src/Nodes/Inline/ImageInlineNode.php +++ b/packages/guides/src/Nodes/Inline/ImageInlineNode.php @@ -20,8 +20,11 @@ final class ImageInlineNode extends InlineNode { public const TYPE = 'image'; - public function __construct(private readonly string $url, private readonly string $altText) - { + public function __construct( + private readonly string $url, + private readonly string $altText, + private readonly string|null $title = null, + ) { parent::__construct(self::TYPE, $url); } @@ -34,4 +37,9 @@ public function getAltText(): string { return $this->altText; } + + public function getTitle(): string + { + return $this->title ?? ''; + } } diff --git a/tests/Integration/tests/markdown/image-title-md/expected/hero-illustration.svg b/tests/Integration/tests/markdown/image-title-md/expected/hero-illustration.svg new file mode 100644 index 000000000..002f8feff --- /dev/null +++ b/tests/Integration/tests/markdown/image-title-md/expected/hero-illustration.svg @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Integration/tests/markdown/image-title-md/expected/index.html b/tests/Integration/tests/markdown/image-title-md/expected/index.html new file mode 100644 index 000000000..6d8c077d7 --- /dev/null +++ b/tests/Integration/tests/markdown/image-title-md/expected/index.html @@ -0,0 +1,8 @@ + +
+

Markdown Image

+ +

Hero Illustrations

+ +
+ diff --git a/tests/Integration/tests/markdown/image-title-md/input/guides.xml b/tests/Integration/tests/markdown/image-title-md/input/guides.xml new file mode 100644 index 000000000..92319864e --- /dev/null +++ b/tests/Integration/tests/markdown/image-title-md/input/guides.xml @@ -0,0 +1,8 @@ + + + + diff --git a/tests/Integration/tests/markdown/image-title-md/input/hero-illustration.svg b/tests/Integration/tests/markdown/image-title-md/input/hero-illustration.svg new file mode 100644 index 000000000..002f8feff --- /dev/null +++ b/tests/Integration/tests/markdown/image-title-md/input/hero-illustration.svg @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Integration/tests/markdown/image-title-md/input/index.md b/tests/Integration/tests/markdown/image-title-md/input/index.md new file mode 100644 index 000000000..a89a5767d --- /dev/null +++ b/tests/Integration/tests/markdown/image-title-md/input/index.md @@ -0,0 +1,3 @@ +# Markdown Image + +![Hero Illustrations](hero-illustration.svg "Some title")