asciidoctor / asciidoctor-diagram

:left_right_arrow: Asciidoctor diagram extension, with support for AsciiToSVG, BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, Erd, GraphViz, Mermaid, Msc, PlantUML, Shaape, SvgBob, Syntrax, UMLet, Vega, Vega-Lite and WaveDrom.
http://asciidoctor.org
MIT License
432 stars 106 forks source link

'Bumping' Ditaa version #76

Closed kubamarchwicki closed 8 years ago

kubamarchwicki commented 8 years ago

Hi, This is a bit 'yak shaving'ish - but here is the story.

Ditaa extension for asciidoctor-diagram (great stuff - btw) allows (recently - as of #69) for ditaa options. One of the options on DItaa sourcecode is "transparent" background (https://github.com/stathissideris/ditaa/blob/master/src/org/stathissideris/ascii2image/core/CommandLineConverter.java#L71). However - this is not a feature available in the downloadable version of DItaa.

When I build Ditaa from source I can easily run it with

{ examples } master » java -jar /tmp/ditaa/releases/ditaa0_9.jar -S -T ditaa.txt                                               /tmp/asciidoctor-diagram/examples  

ditaa version 0.9, Copyright (C) 2004--2009  Efstathios (Stathis) Sideris

Running with options:
no-shadows
transparent
Reading file: ditaa.txt
Rendering to file: ditaa_3.png
Done in 0sec

Then for a following snippet

                   +-------------+
                   | asciidoctor |-------+
                   |  diagram    |       |
                   +-------------+       | png out
                       ^                 |
                       | ditaa in        |
                       |                 v
 +--------+   +--------+----+    /---------------\
 |        | --+ asciidoctor +--> |               |
 |  Text  |   +-------------+    |Beatiful output|
 |Document|   |   !magic!   |    |               |
 |     {d}|   |             |    |               |
 +---+----+   +-------------+    \---------------/
     :                                   ^
     |          Lots of work             |
     +-----------------------------------+

I got result as expected (with transparent background!) ditaa_3

However that doesn't get supported by the diagram extension. The ditaamini0_9.jar doesn't look to me as a standard ditaa distribution and simple replacement of an old jar with a new build triggers a following error

Exception in thread "main" java.lang.NoSuchMethodError: org.stathissideris.ascii2image.text.TextGrid.loadFrom(Ljava/io/InputStream;Lorg/stathissideris/ascii2image/core/ProcessingOptions;)V
    at org.asciidoctor.diagram.Ditaa.generate(Ditaa.java:61)
    at org.asciidoctor.diagram.CommandProcessor.processRequest(CommandProcessor.java:34)
    at org.asciidoctor.diagram.CommandServer.processRequests(CommandServer.java:38)
    at org.asciidoctor.diagram.CommandServer.main(CommandServer.java:20)
asciidoctor-diagram: ERROR: Failed to generate image: end of file reached

Now, when I browse further - I see some more changes are required in here https://github.com/pepijnve/asciidoctor-diagram-java/blob/master/src/main/java/org/asciidoctor/diagram/Ditaa.java#L33

Before I start drilling there and fiddling with the code further, I just want to confirm that my thoughts are right. The steps should be

Additional question, if the freshly built ditta.jar is not a drop-in replacement how can I reproduce the built of ditaamini0_9.jar

--Kuba

PS. My usecase. I started to use diagram for my training presentations. I have the diagrams together with slides and when it gets rendered into any html deck - the transparent background would make a bit more sense in some cases.

pepijnve commented 8 years ago

Hi Kuba,

When I was adding support for Ditaa in asciidoctor-diagram there was no proper release binary of Ditaa available for download. I forked the project, did some cleanup and packaged that up as ditaamini. It's 'mini' since it's pretty small and I stripped out all the code that requires additional external dependencies. Source repo is at https://github.com/pepijnve/ditaa

You're right that I did make some other small changes. I added that method to TextGrid to load Ditaa diagram source from an InputStream. That's much more convenient for my particular usage of Ditaa.

As for the missing transparent options, I accidentally missed it. I had based myself on the documentation at http://ditaa.sourceforge.net/#usage which doesn't list all the available options. I've gone ahead and added support for the missing rendering options that ditaa supports (transparent, background and fixed-slope).

kubamarchwicki commented 8 years ago

Woow that was fast! :+1: Thx - the description was quite elaborate as I was thinking of setting up pull request but you didt so fast :) great stuff

--Kuba

pepijnve commented 8 years ago

The 1.3.0 release was long overdue and this request gave me just enough of a push to just finish it. :)

mojavelinux commented 8 years ago

:+1: