Closed mtnpke closed 1 year ago
I can understand the issue regarding superfluous whitespace. I can really mess with the harmony of an image.
Current | Fixed |
---|---|
A quick dig in the code leads me to believe this shouldn't be too hard to resolve, although I would have to check before committing myself to anything.
As far as I can see, this behaviour comes from the $getComponent
, $getContainer
, $getPerson
and $getSystem
, and $getNode
functions, respectively.
For getSystem
and getPerson
it would be neccesary to add an extr if
to check for the label.
The current code reads:
That would have to be changed to:
!if ($descr == "") && ($sprite != "")
!if ($label == "")
!return $getSprite($sprite)
!else
!return $getSprite($sprite)+'\n== '+$breakLabel($label)
!endif
!endif
For getComponent
, getContainer
, and getNode*
the code is:
which would need to be changed to:
!if ($label != "")
...
!endif
@kirchsth Can I ask you for feedback and/or to tell me what I am missing? 😁
@Potherca: Thank you for the implementation.
I think it is complete I only would
!if ($link != "")
!$usedNewLine = ']]**\n**[[' + $link + ' '
!$rel = $rel + '**[[' + $link + ' ' + $breakText($label, $usedNewLine) + ']]**'
!else
!$usedNewLine = '**\n**'
!$rel = $rel + '**' + $breakText($label, $usedNewLine) + '**'
!endif
$getElementBase()
base call too (maybe with a better name instead of Base)
!function $getElementBase($label, $techn, $descr, $sprite)
!$element = ""
!if ($sprite != "")
!$element = $element + $getSprite($sprite) + '\n'
!endif
!if ($label != "") -----------------
!$element = $element + '== ' + $breakLabel($label)
!endif -----------------
!if ($techn != "")
!$element = $element + '\n//<size:' + $TECHN_FONT_SIZE + '>[' + $breakTechn($techn, '-1') + ']</size>//'
!endif
!if ($descr != "")
!$element = $element + '\n\n' + $descr
!endif
!return $element
!endfunction
!function $getComponent($label, $techn, $descr, $sprite) $getElementBase($label, $techn, $descr, $sprite) !endfunction
!function $getContainer($label, $techn, $descr, $sprite) $getElementBase($label, $techn, $descr, $sprite) !endfunction
!function $getPerson($label, $descr, $sprite) !if ($sprite == "") && ($defaultPersonSprite != "") !$sprite = $defaultPersonSprite !endif $getElementBase(.., $techn="", ...) !endfunction
!function $getSystem($label, $descr, $sprite) $getElementBase(.., $techn="", ...) !endfunction
- and update $getNode(), $getNode_L(), $getNode_R() with a common $getNodeBase() implementation (but with very low priority)
Please be aware that I didn't check anything.
**And I think we should at least test if all arguments are empty that it is not "crashing".**
Thank you and best regards
Helmut
Hi @mtnpke, I implemented it in https://github.com/plantuml-stdlib/C4-PlantUML/pull/285. Can you please check it? Thank you and BR Helmut
@kirchsth Yeah, it's working great :) @Potherca Thanks, much obliged!
Hi!
I think a nice feature to have would be to be able to declare systems, containers etc. that only contain a sprite and no label. This is useful for including a logo sprite that already has text in it, so having it as label text would be repetitive. Right now, if you write for example
System_Ext(Test, "", $sprite="img:test.png")
, you will get an extra blank line in the rectangle after the image, which is visually unpleasing.