Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlantUML Build-In Function %filename not supported #30

Open
SieDa opened this issue Sep 15, 2024 · 2 comments
Open

PlantUML Build-In Function %filename not supported #30

SieDa opened this issue Sep 15, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@SieDa
Copy link

SieDa commented Sep 15, 2024

Description
Running the example file PlantUML-buildin-functions.puml in NotePad delivers no value to %filename.
Running the example file in Windows 10 from Git Bash with the same JAR File provides a proper output.

Reproduction
Steps to reproduce the behavior:

  1. Update to PlantUmlViewer/plantuml-1.2024.3.jar
  2. Process the file in Notepad and export to SVG PlantUML-buildin-functions-notepad.svg
  3. Process the file in Git Bash with
java -jar "c:/Program Files/Notepad++/plugins/PlantUmlViewer/plantuml-1.2024.3.jar"
    -tsvg -charset UTF-8 PlantUML-buildin-functions.puml
  1. Compare both output files (attached examples)
    PlantUML-buildin-functions-gitBash-win10
    PlantUML-buildin-functions-gitBash-win10
    PlantUML-buildin-functions-notepad-win10
    PlantUML-buildin-functions-notepad-win10

Expected behavior

  1. I would expect to be able to put the %filename() into the footer.
  2. The example might be good for the plantuml manual to explain buildin functions.
  3. The output of Notepad processing is supported by the windows explorer preview.
    But the embedding of code differs from that in the PlantUML Standard.

Can you explain the difference in processing XML Export results in Notepad to the Git Bash processing (Comparing the code makes this visible)?

Is it possible to run it in Notepad and achieve the same result:

bash:
<?xml version="1.0" encoding="us-ascii" standalone="no"?> ...
notepad:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">...

Code
PlantUML-buildin-functions.puml

@startuml

left header
How to place an SVG-Logo here? 
'<img: src="image.png"{scale=0.12}>
endheader

left footer
Rendered with PlantUML version %version() on %date("yyyy-MM-dd' at 'hh:mm") from file: %filename()
endfooter

title PlantUML buildin functions

l -> r
note left
Name 
  Description 
  Example 
  > output

%date ("yyyy-MM-dd' at 'hh:mm")
  Retrieve current date. 
  You can provide an optional format for the date 
  > %date("yyyy-MM-dd' at 'hh:mm")

%dirpath ()
  Retrieve current dirpath 
  > %dirpath() 

%false ()
  Return always false 
  > %false() 

%file_exists ("./PlantUML-buildin-functions.puml")
  Check if a file exists on the local filesystem 
  > %file_exists("./PlantUML-buildin-functions.puml")

%filename ()
  Retrieve current filename 
  > %filename() 

%function_exists ("%filename")
  Check if a function exists 
  > %function_exists("%filename")

%set_variable_value ("$my_value","my_value")
  Set a global variable 
  > %set_variable_value("$my_value","my_value")

%get_variable_value ("$my_value")
  Retrieve some variable value  
  > %get_variable_value("$my_value")

%getenv ("Path")
  Retrieve environment variable value 
  > %getenv("Path") 

%intval ("42")
  Convert a String to Int 
  > %intval("42") 
end note
note right
%lower ("Hello")
  Return a lowercase string 
  > %lower("Hello")

%newline () X
  Return a newline 
  > %newline() X

%not (2+2==4)
  Return the logical negation of an expression 
  > %not(2+2==4)

%string (1 + 2)
  Convert an expression to String 
  > %string(1 + 2) 

%strlen ("foo")
  Calculate the length of a String 
  > %strlen("foo") 

%strpos ("abcdef", "ef")
  Search a substring in a string 
  > %strpos("abcdef", "ef") 

%substr ("abcdef", 3, 2)
  Extract a substring. Takes 2 or 3 arguments 
  > %substr("abcdef", 3, 2) 

%true ()
  Return always true 
  > %true() 

%upper ("Hello")
  Return an uppercase string 
  > %upper("Hello") 

%variable_exists ("$my_value")
  Check if a variable exists 
  > %variable_exists("$my_value") 

%version ()
  Return PlantUML current version 
  > %version()
end note

@enduml

Environment

  • Windows: [Win10]
  • Notepad++ version: [8.6.9 64-bit]
  • PlantUML PlugIn 1.7.0.11
  • PlantUML Version 1.2024.3

Additional information

  1. Maybe the parameter -filedir might enable the proper setting.

  2. Also the !include of files with relative path descriptions ./file.puml or ../path/file.puml
    does not work in my environment of Notepad++.

@SieDa SieDa added the bug Something isn't working label Sep 15, 2024
@SieDa
Copy link
Author

SieDa commented Sep 15, 2024

All environment variables are delivered by printenv, e.g.:

OS=Windows_NT
HOMEDRIVE=C:

We could not get this working for the %getenv() function at all, to access them, as shown in the example above:

%getenv ("OS")
  Retrieve environment variable value 
  > %getenv("OS") 

@Fruchtzwerg94
Copy link
Owner

Fruchtzwerg94 commented Sep 16, 2024

Hi @SieDa ,

thanks for your report. Filename was supported yet since it was not overridden by the plugin accordingly. I've fixed this in the latest commit. Try out the following build and let me know if it works for you: Run 10881066927.

Unfortunately, it seems like PlantUML isn't supporting %dirpath() the same way so this still will not work. I've created an issue at the PlantUML repository. Maybe they have a look at it soon.

BR,
Philipp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants