Add null character to %filename() on server (and PicoWeb)

0 votes
asked Dec 23, 2020 in Wanted features by Serge Wenger Work (14,600 points)

Some plugins (Visual Studio code, Chrome, ...) can use a local version of plantuml or on a web sever. The web server is really faster but has a big issue with %filename(). This version return an empty string on a server and generate error with Title, Caption, ...

@startuml
Title %filename()
actor actor [[{actor}]]
caption %filename()
@enduml

See on PlantUML Server

The workaround is to add a null character after like this:

@startuml
Title %filename() <U+0000>
actor actor [[{actor}]]
caption %filename() <U+0000>
@enduml

Would it be possible to include the null character directly in the %filename() function in server mode? 

commented Dec 23, 2020 by The-Lu (48,920 points)

Hello PlantUML team,

Or the opposite (to avoid to add null char...) [That is only a proposal...]:

  • Could you allow the common commands (title, caption, header, footer or legend) to accept empty string as argument, and does not produce a 'Syntax Error'?

Example:

@startuml
Title ""
Caption
@enduml

[See on PlantUML server]

Thank for your support,
Regards,
Th.

commented Dec 23, 2020 by Serge Wenger Work (14,600 points)

Or better, use the filename just after @startuml like this:

@startuml Thefilename
Title %filename()
actor actor [[{actor}]]
caption %filename()
@enduml

With local version of plantuml, it generate the image in TheFilename.png  (or svg)

In the server version %filename() could return Thefilename

commented Dec 23, 2020 by The-Lu (48,920 points)

Hello Serge and PlantUML team,

For %filename() and filename after @startuml [your Thefilename], see also:

Regards,
Th.

commented Jan 4, 2021 by Serge Wenger Work (14,600 points)

Hello PlantUML team,

Some news about one of the possibilities to solve this problem

commented Jan 4, 2021 by plantuml (278,240 points)

With new beta http://beta.plantuml.net/plantuml.jar and on the online server, you can now have:

title ""

This was the easiest to implement.

Tell us if you find issues!

commented Jan 5, 2021 by Serge Wenger Work (14,600 points)

Thanks, for other use (caption, etc.) as workaround I create a function:

!function $filename2()
!if (%strlen(%filename())) 
!return %filename()
!else
!return "Generated from web server"
!endfunction

1 Answer

0 votes
answered Jan 9, 2021 by kirchsth (2,900 points)
selected Jan 11, 2021 by Serge Wenger Work
 
Best answer

I think the simples solution of the problem are surrounding turned comma. This should work in all required scenarios.

@startuml
Title "%filename()"
actor actor [[{actor}]]
caption "%filename()"
@enduml

Best regards
Helmut

...