structurizr / export

Export models and views to external formats.

Home Page:https://docs.structurizr.com/export

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PlantUML export fails when element names are Unicode characters

xuning97 opened this issue · comments

for user = person "用户1", export to plantuml, it becomes
person "==用户1\n<size:10>[Person]</size>" <<1>> as 1

If it's the [Person] text that you're referring to, you can change this via the terminology keyword. For example:

workspace {

    model {
        user = person "用户1"
    }

    views {
        systemLandscape "MyDiagramKey" {
            include *
        }
        
        terminology {
            person "xxx"
        }
    }
    
}

Here's an example.

commented

I think point is that userId (alias) is rendered with error: see "as 1" fragment in result.

I get same issue with russian names ob objects.
As I could understand reasons - thats from https://github.com/structurizr/export/blob/main/src/main/java/com/structurizr/export/plantuml/AbstractPlantUMLExporter.java#L159
filter function - it's delete any non [a-zA-Z_0-9] characters.
But - it's not realy nessesary in PlantUML to make so strict rules for Ids: see https://plantuml.com/ru/unicode

My suggest for patch is: change regexp puttern to unicode aware: from "\W" to "(?U)\W".
see for explanation: https://stackoverflow.com/questions/4304928/unicode-equivalents-for-w-and-b-in-java-regular-expressions

Do you have an example DSL that doesn't work?

commented

Here is example:

workspace {

    model {
        user = person "Пользователь"
    }

    views {
        systemLandscape "MyDiagramKey" {
            include *
        }

        terminology {
            person "xxx"
        }
    }
}

command for export:
structurizr.bat export -workspace test\workspace.dsl -format plantuml -output .\export

result plantUML file:

@startuml
title System Landscape

top to bottom direction

skinparam {
  shadowing false
  arrowFontSize 10
  defaultTextAlignment center
  wrapWidth 200
  maxMessageSize 100
}

hide stereotype

skinparam rectangle<<>> {
  BackgroundColor #dddddd
  FontColor #000000
  BorderColor #9a9a9a
}

rectangle "==Пользователь\n<size:10>[Person]</size>" <<>> as 

@enduml

Take a note for empty alias and stereotype name in difinitions.

Thanks ... I think this is different from the original issue, so I've changed the title.