Ditaa parsing errors

0 votes
asked Dec 31, 2021 in Bug by eduardomozart (120 points)

PlantUML has built-in ditaa diagram parsing (). When trying to parse the following Ditaa diagrams, an error happens:

/-----------------\
| Things to do    |
| cGRE            |
| o Cut the grass |
| o Buy jam       |
| o Fix car       |
| o Make website  |
\-----------------/

/----\ /----\
|c33F| |cC02|
|    | |    |
\----/ \----/

/----\ /----\
|c1FF| |c1AB|
|    | |    |
\----/ \----/

           +----------+     +----------+     +----------+     +---------------+
           | Client 1 |     | Client 2 |     | Client 3 |     | OSD:Object ID |
           +----------+     +----------+     +----------+     +---------------+
                 |                |                |                  |
                 |                |                |                  |
                 |                |  Watch Object  |                  |
                 |--------------------------------------------------->|
                 |                |                |                  |
                 |<---------------------------------------------------|
                 |                |   Ack/Commit   |                  |
                 |                |                |                  |
                 |                |  Watch Object  |                  |
                 |                |---------------------------------->|
                 |                |                |                  |
                 |                |<----------------------------------|
                 |                |   Ack/Commit   |                  |
                 |                |                |   Watch Object   |
                 |                |                |----------------->|
                 |                |                |                  |
                 |                |                |<-----------------|
                 |                |                |    Ack/Commit    |
                 |                |     Notify     |                  |
                 |--------------------------------------------------->|
                 |                |                |                  |
                 |<---------------------------------------------------|
                 |                |     Notify     |                  |
                 |                |                |                  |
                 |                |<----------------------------------|
                 |                |     Notify     |                  |
                 |                |                |<-----------------|
                 |                |                |      Notify      |
                 |                |       Ack      |                  |
                 |----------------+---------------------------------->|
                 |                |                |                  |
                 |                |       Ack      |                  |
                 |                +---------------------------------->|
                 |                |                |                  |
                 |                |                |        Ack       |
                 |                |                |----------------->|
                 |                |                |                  |
                 |<---------------+----------------+------------------|
                 |                     Complete

The following Ditaa diagrams parses incorrectly:
Color codes
/-------------+-------------\
|cRED RED     |cBLU BLU     |
+-------------+-------------+
|cGRE GRE     |cPNK PNK     |
+-------------+-------------+
|cBLK BLK     |cYEL YEL     |
\-------------+-------------/

           +-----+
            | {o} |
            |     |
            +--+--+       /---------\               /---------\
               |          |  Ceph   |               |  Ceph   |
            ---+---*----->|         |<------------->|         |
               |     uses | Clients |               | Servers |
               |          \---------/               \---------/
            /--+--\
            |     |
            |     |
             actor

            Upstream Code                       Your Local Environment

           /----------\        git clone           /-------------\
           |   Ceph   | -------------------------> | ceph/master |
           \----------/                            \-------------/
                ^                                    |
                |                                    | git branch fix_1
                | git merge                          |
                |                                    v
           /----------------\  git commit --amend   /-------------\
           | ninja check    |---------------------> | ceph/fix_1  |
           | ceph--qa--suite|                       \-------------/
           \----------------/                        |
                ^                                    | fix changes
                |                                    | test changes
                | review                             | git commit
                |                                    |
                |                                    v
           /--------------\                        /-------------\
           |   github     |<---------------------- | ceph/fix_1  |
           | pull request |         git push       \-------------/
           \--------------/

All diagrams above were taken by official Ditaa documentation available at http://ditaa.sourceforge.net/ and from Ceph documentation available at https://github.com/ceph/ceph/search?utf8=%E2%9C%93&q=ditaa
From what I've seen, it seems to render incorrectly Ditaa diagrams that contains lines equal "/" and "\"
commented Jan 1 by Martin (6,780 points)

I don't use ditaa myself, so I might be missing some subtleties, but I cut&pasted all your examples into the plantuml online server and couldn't figure out what the problems were. Maybe check you have a latest version of Plantuml?

 OK, I did have to adjust the last row of example#3 to avoid an error.  And corrected an obvious offset error in the first row of diagram#5. 

Here's what I get  - perhaps you can elaborate on the problems in them - 
1)

click diagram for online server

2)

click diagram for online server

3)

click diagram for online server

4)

click diagram for online server

5)

click diagram for online server

6)

click diagram for online server

commented Jan 1 by eduardomozart (120 points)
Hello,

Thank you for your fast response!

I'm using PlantUML On-line server also.

I noticed that all diagrams rendered correctly using "@startditaa" and "@endditaa", but it fails if we use

@startuml
ditaa
' insert Ditaa diagram here
@enduml

But the PlantUML documentation states that this kind of declaration is also possible, so I believe it's incorrectly renders are somehow related to how PlantUML parse Ditaa diagrams that starts with @startuml syntax.
commented Jan 1 by Martin (6,780 points)

OK, that makes more sense now.  I hadn't noticed the alternative syntax.
The bug is very strange to cause example#4 to do this:

1 Answer

0 votes
answered Jan 1 by Martin (6,780 points)
edited Jan 1 by Martin

The problem is that @startuml is invoking the syntax for a trailing "\" to mean line continuation.  Normally putting "\" at the end of a line causes it to fuse to the next line.  E.g.

@startuml
rectangle my_full\
_name
@enduml

So a workaround is to append something that doesn't affect the diagram - a block comment seems to work.
e.g.

​@startuml
ditaa
Color codes
/-------------+-------------\ /' fix trailing backslash '/
|cRED RED     |cBLU BLU     |
+-------------+-------------+
|cGRE GRE     |cPNK PNK     |
+-------------+-------------+
|cBLK BLK     |cYEL YEL     |
\-------------+-------------/
@enduml

(Note that example#3 is the exception - it didn't have any trailing slashes, instead I had to elongate the lifelines on the last row to get it to draw.  I've not found the example in your sources to know whether that's a problem with your copying or if it is a genuine example of a valid ditaa diagram that doesn't render in Plantuml).

Ideally Plantuml would fix so that a trailing \ doesn't mean continuation inside a ditaa diagram.

...