Skip to content

Commit

Permalink
Merge pull request #325 from Roave/fix-angry-whitespace-bug
Browse files Browse the repository at this point in the history
1.7.x bugfix - fixed whitespace bug
  • Loading branch information
Ocramius authored Mar 20, 2023
2 parents 06823e7 + dd4cda5 commit bd08f40
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/Formatter/RenderPlantUmlDiagramInline.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
);
Expand All @@ -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),
));
}
Expand Down
12 changes: 12 additions & 0 deletions test/fixture/docbook/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,25 @@ Links [here](https://www.google.com). **Bold**, _italic_, ~~strikethrough~~, `in

## A diagram

Test with filename:

```puml
@startuml dummy_filename
Bob->Alice : hello
hexagon TestingHexagon
@enduml
```

Test without filename:

```puml
@startuml
skinparam package {
BackGroundColor Seashell
}
@enduml
```

## Some images

Here are some images:
Expand Down
6 changes: 6 additions & 0 deletions test/fixture/expectations/out.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ <h2>Subtitle</h2>

<h2>A diagram</h2>

<p>Test with filename:</p>

<p><img src="data:image/png;base64,iVBORw%s" alt="Diagram" /></p>

<p>Test without filename:</p>

<p><img src="data:image/png;base64,iVBORw%s" alt="Diagram" /></p>

<h2>Some images</h2>
Expand Down

0 comments on commit bd08f40

Please sign in to comment.