How can I escape double underscores in a namespace name?

0 votes
asked Jul 11, 2023 in To be sorted by mforkel

I would like to use a namespace name that starts and ends with double underscores, e.g.

@startuml
namespace __builtin__ {
}
@enduml

But the name is displayed as builtin.

How can I escape the underscores?

commented Sep 5, 2023 by Dschey

The escape character ~ does not work for me where I have a description with a variable name that has a double underscore in the name e.g. "phonenumber__m".

The problem is that PlantUML treats this as underline and shows e.g. "phonenumber__m, city__c" as underlined before the next double underscore like this: "phonenumber__m, cityc".

Any ideas?

commented Sep 5, 2023 by The-Lu (64,760 points)

Hi D., and all,

You must to escape with `~` before the `_`, as:

@startuml
namespace "phonenumber~__m, city~__c" as example {
}
@enduml

If that can help,
Enjoy,

Regards,
Th.

commented Sep 6, 2023 by Dschey

yes Many thanks The-Lu. This works. Issue solved. Excellent smiley

1 Answer

0 votes
answered Jul 12, 2023 by The-Lu (64,760 points)

Hello M.,

Here is a solution:

  • using plantuml escape character '~'
  • and using 'double quoted label' and 'alias'
@startuml
namespace "~__builtin__" as builtin {
}
@enduml

Then we can observe the expected result:

Enjoy,
Regards,
Th.

commented Jul 16, 2023 by mforkel

Thanks, worked for me. smiley

The rules for escaping seem to depend on the context. I found that in an extension relation, I have to write something like

"~__builtin__.class" <|-- namespace.subclass

Where do I find these rules in the documentation?

...