From dd4cda5a7e802fa8628570805ffe46580e95e83b Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Mon, 20 Mar 2023 08:34:25 +0000 Subject: [PATCH] Fixed whitespace bug that caused the plantuml to be rendered to be wrong --- Dockerfile | 2 +- src/Formatter/RenderPlantUmlDiagramInline.php | 6 +++--- test/fixture/docbook/test.md | 12 ++++++++++++ test/fixture/expectations/out.html | 6 ++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6c631681..dd9d9c2d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,7 +49,7 @@ RUN \ wkhtmltopdf \ && mkdir -p /docs-package/pdf /app /docs-src/book /docs-src/templates /docs-src/features -ADD https://github.com/plantuml/plantuml/releases/download/v1.2022.4/plantuml-1.2022.4.jar app/bin/plantuml.jar +ADD https://github.com/plantuml/plantuml/releases/download/v1.2023.4/plantuml-1.2023.4.jar app/bin/plantuml.jar ENV XDG_RUNTIME_DIR=/tmp/runtime-root FROM base-with-dependencies AS production-composer-dependencies diff --git a/src/Formatter/RenderPlantUmlDiagramInline.php b/src/Formatter/RenderPlantUmlDiagramInline.php index edbf879a..28c73e69 100644 --- a/src/Formatter/RenderPlantUmlDiagramInline.php +++ b/src/Formatter/RenderPlantUmlDiagramInline.php @@ -47,7 +47,7 @@ function (array $m) use ($page) { $this->logger->debug(sprintf('[%s] Found PlantUML diagram to render in %s', self::class, $page->slug())); // fix any "@startuml filename" first lines to omit the filename - $match = preg_replace('/^(\s*@startuml)(\s.*)$/m', '\\1', $match, count: $startUmls); + $match = preg_replace('/^(\s*@startuml)(.*)$/m', '\\1', $match, count: $startUmls); if ($startUmls === 0) { throw new RuntimeException(sprintf( @@ -65,7 +65,7 @@ function (array $m) use ($page) { /** @psalm-suppress ForbiddenCode */ exec( - escapeshellcmd('java -jar ' . self::PLANTUML_JAR . ' ' . $pumlFilename) . ' 2>&1', + escapeshellcmd('java -jar ' . self::PLANTUML_JAR . ' -v ' . $pumlFilename) . ' 2>&1', $output, $exitCode, ); @@ -75,7 +75,7 @@ function (array $m) use ($page) { throw new RuntimeException(sprintf( 'Failed to render PUML in %s - starts "%s". Output was: %s', $page->slug(), - substr($match, 0, 15), + substr($match, 0, 30), implode("\n", $output), )); } diff --git a/test/fixture/docbook/test.md b/test/fixture/docbook/test.md index c49e4590..21ef6792 100644 --- a/test/fixture/docbook/test.md +++ b/test/fixture/docbook/test.md @@ -30,6 +30,8 @@ Links [here](https://www.google.com). **Bold**, _italic_, ~~strikethrough~~, `in ## A diagram +Test with filename: + ```puml @startuml dummy_filename Bob->Alice : hello @@ -37,6 +39,16 @@ hexagon TestingHexagon @enduml ``` +Test without filename: + +```puml +@startuml +skinparam package { + BackGroundColor Seashell +} +@enduml +``` + ## Some images Here are some images: diff --git a/test/fixture/expectations/out.html b/test/fixture/expectations/out.html index 2ab4de32..309bae34 100644 --- a/test/fixture/expectations/out.html +++ b/test/fixture/expectations/out.html @@ -60,6 +60,12 @@

Subtitle

A diagram

+

Test with filename:

+ +

Diagram

+ +

Test without filename:

+

Diagram

Some images