Skip to content

Commit

Permalink
Add PlantUML no-metadata option (#1611)
Browse files Browse the repository at this point in the history
* Add 'no-metadata' argument
* Add PlantUML no-metadata option to documentation
* Add smoke test for PlantUML 'no-metadata' option

fixes #1610
  • Loading branch information
felixvanoost committed Aug 13, 2023
1 parent 5adac1c commit a7b6b36
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions ci/tests/smoke.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const tests = [
{ engine: 'mermaid', file: 'contribute.mmd', options: {}, outputFormat: ['svg'] },
{ engine: 'bpmn', file: 'example.bpmn', options: {}, outputFormat: ['svg'] },
{ engine: 'plantuml', file: 'architecture.puml', options: {}, outputFormat: ['svg', 'pdf', 'png', 'txt'] },
{ engine: 'plantuml', file: 'architecture.puml', options: { 'no-metadata': 'true' }, outputFormat: ['svg', 'png'] },
{ engine: 'svgbob', file: 'cloud.bob', options: {}, outputFormat: ['svg'] },
{ engine: 'nomnoml', file: 'pirate.nomnoml', options: {}, outputFormat: ['svg'] },
{ engine: 'packetdiag', file: 'packet.diag', options: {}, outputFormat: ['svg', 'png'] },
Expand Down
6 changes: 5 additions & 1 deletion docs/modules/setup/pages/diagram-options.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ The complete list of options is available in Mermaid source code at: https://git

|Use a specific theme (it will prepend the `!theme` directive in your diagram)

|no-metadata
|_flag_ +
empty string ("")
|Do not save the diagram's source code in the generated SVG/PNG metadata
|===

== Structurizr
Expand Down Expand Up @@ -233,7 +237,7 @@ The complete list of options is available in Mermaid source code at: https://git

|stroke-width
|_any_ +
*`2`*
*`2`*
|Stroke width for all lines

|===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,20 @@ public byte[] handle(int exitValue, byte[] stdout, byte[] stderr) {

public byte[] convert(String source, FileFormat format, JsonObject options) throws IOException, InterruptedException {
List<String> commands = new ArrayList<>();
String theme = options.getString("theme");
commands.add(binPath);
commands.add("-pipe");
commands.add("-t" + (format == FileFormat.BASE64 ? FileFormat.PNG.getName() : format.getName()));
commands.add("-timeout");
commands.add(String.valueOf(this.convertTimeout.timeUnit().toSeconds(this.convertTimeout.duration())));
String theme = options.getString("theme");
if (theme != null && !theme.isBlank()) {
commands.add("-theme");
commands.add(theme);
}
String no_metadata = options.getString("no-metadata");
if (no_metadata != null) {
commands.add("-nometadata");
}
byte[] result = commander.execute(source.getBytes(), commands.toArray(new String[0]));
if (format == FileFormat.BASE64) {
final String encodedBytes = "data:image/png;base64," + Base64.getUrlEncoder().encodeToString(result).replaceAll("\\s", "");
Expand Down

0 comments on commit a7b6b36

Please sign in to comment.