diff --git a/packages/guides/src/Twig/AssetsExtension.php b/packages/guides/src/Twig/AssetsExtension.php index 16393d147..1bcb3fee3 100644 --- a/packages/guides/src/Twig/AssetsExtension.php +++ b/packages/guides/src/Twig/AssetsExtension.php @@ -156,25 +156,27 @@ private function copyAsset( } $canonicalUrl = $this->documentNameResolver->canonicalUrl($renderContext->getDirName(), $sourcePath); + $normalizedSourcePath = $this->documentNameResolver->canonicalUrl($renderContext->getDirName(), $sourcePath); + $outputPath = $this->documentNameResolver->absoluteUrl( $renderContext->getDestinationPath(), $canonicalUrl, ); try { - if ($renderContext->getOrigin()->has($sourcePath) === false) { + if ($renderContext->getOrigin()->has($normalizedSourcePath) === false) { $this->logger->error( - sprintf('Image reference not found "%s"', $sourcePath), + sprintf('Image reference not found "%s"', $normalizedSourcePath), $renderContext->getLoggerInformation(), ); return $outputPath; } - $fileContents = $renderContext->getOrigin()->read($sourcePath); + $fileContents = $renderContext->getOrigin()->read($normalizedSourcePath); if ($fileContents === false) { $this->logger->error( - sprintf('Could not read image file "%s"', $sourcePath), + sprintf('Could not read image file "%s"', $normalizedSourcePath), $renderContext->getLoggerInformation(), ); diff --git a/tests/Integration/tests/markdown/image-path-relative-md/expected/dir1/dir2/index.html b/tests/Integration/tests/markdown/image-path-relative-md/expected/dir1/dir2/index.html new file mode 100644 index 000000000..e630723f5 --- /dev/null +++ b/tests/Integration/tests/markdown/image-path-relative-md/expected/dir1/dir2/index.html @@ -0,0 +1,11 @@ + +
+

Dir 2 Title

+ +

Lorem Ipsum Dolor.

+ + +

Hero Illustrations

+ +
+ diff --git a/tests/Integration/tests/markdown/image-path-relative-md/expected/dir1/dir2/somePage.html b/tests/Integration/tests/markdown/image-path-relative-md/expected/dir1/dir2/somePage.html new file mode 100644 index 000000000..4f74e403b --- /dev/null +++ b/tests/Integration/tests/markdown/image-path-relative-md/expected/dir1/dir2/somePage.html @@ -0,0 +1,8 @@ + +
+

Some Page in dir 2

+ +

Lorem Ipsum Dolor.

+ +
+ diff --git a/tests/Integration/tests/markdown/image-path-relative-md/expected/dir1/index.html b/tests/Integration/tests/markdown/image-path-relative-md/expected/dir1/index.html new file mode 100644 index 000000000..b373b8a7f --- /dev/null +++ b/tests/Integration/tests/markdown/image-path-relative-md/expected/dir1/index.html @@ -0,0 +1,11 @@ + +
+

Dir 1 Title

+ +

Lorem Ipsum Dolor.

+ + +

Hero Illustrations

+ +
+ diff --git a/tests/Integration/tests/markdown/image-path-relative-md/expected/images/hero-illustration.svg b/tests/Integration/tests/markdown/image-path-relative-md/expected/images/hero-illustration.svg new file mode 100644 index 000000000..002f8feff --- /dev/null +++ b/tests/Integration/tests/markdown/image-path-relative-md/expected/images/hero-illustration.svg @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Integration/tests/markdown/image-path-relative-md/expected/index.html b/tests/Integration/tests/markdown/image-path-relative-md/expected/index.html new file mode 100644 index 000000000..c585761b4 --- /dev/null +++ b/tests/Integration/tests/markdown/image-path-relative-md/expected/index.html @@ -0,0 +1,8 @@ + +
+

Document Title

+ +

Lorem Ipsum Dolor.

+ +
+ diff --git a/tests/Integration/tests/markdown/image-path-relative-md/input/dir1/dir2/index.md b/tests/Integration/tests/markdown/image-path-relative-md/input/dir1/dir2/index.md new file mode 100644 index 000000000..e3f31ad4c --- /dev/null +++ b/tests/Integration/tests/markdown/image-path-relative-md/input/dir1/dir2/index.md @@ -0,0 +1,5 @@ +# Dir 2 Title + +Lorem Ipsum Dolor. + +![Hero Illustrations](../../images/hero-illustration.svg) diff --git a/tests/Integration/tests/markdown/image-path-relative-md/input/dir1/dir2/somePage.md b/tests/Integration/tests/markdown/image-path-relative-md/input/dir1/dir2/somePage.md new file mode 100644 index 000000000..082675e84 --- /dev/null +++ b/tests/Integration/tests/markdown/image-path-relative-md/input/dir1/dir2/somePage.md @@ -0,0 +1,4 @@ + +# Some Page in dir 2 + +Lorem Ipsum `Dolor`. diff --git a/tests/Integration/tests/markdown/image-path-relative-md/input/dir1/index.md b/tests/Integration/tests/markdown/image-path-relative-md/input/dir1/index.md new file mode 100644 index 000000000..8b7ff3f18 --- /dev/null +++ b/tests/Integration/tests/markdown/image-path-relative-md/input/dir1/index.md @@ -0,0 +1,5 @@ +# Dir 1 Title + +Lorem Ipsum Dolor. + +![Hero Illustrations](../images/hero-illustration.svg) diff --git a/tests/Integration/tests/markdown/image-path-relative-md/input/guides.xml b/tests/Integration/tests/markdown/image-path-relative-md/input/guides.xml new file mode 100644 index 000000000..4759d605e --- /dev/null +++ b/tests/Integration/tests/markdown/image-path-relative-md/input/guides.xml @@ -0,0 +1,11 @@ + + + + diff --git a/tests/Integration/tests/markdown/image-path-relative-md/input/images/hero-illustration.svg b/tests/Integration/tests/markdown/image-path-relative-md/input/images/hero-illustration.svg new file mode 100644 index 000000000..002f8feff --- /dev/null +++ b/tests/Integration/tests/markdown/image-path-relative-md/input/images/hero-illustration.svg @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Integration/tests/markdown/image-path-relative-md/input/index.md b/tests/Integration/tests/markdown/image-path-relative-md/input/index.md new file mode 100644 index 000000000..9f6ae85ae --- /dev/null +++ b/tests/Integration/tests/markdown/image-path-relative-md/input/index.md @@ -0,0 +1,3 @@ +# Document Title + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/markdown/image-path-relative-md/input/somePage.md b/tests/Integration/tests/markdown/image-path-relative-md/input/somePage.md new file mode 100644 index 000000000..fa56e2e48 --- /dev/null +++ b/tests/Integration/tests/markdown/image-path-relative-md/input/somePage.md @@ -0,0 +1,6 @@ + +# Some Page + +Lorem Ipsum `Dolor`. + +![Hero Illustrations](images/hero-illustration.svg)