Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call ditaa with command line arguments #69

Closed
saschazelzer opened this issue Mar 24, 2015 · 13 comments
Closed

Call ditaa with command line arguments #69

saschazelzer opened this issue Mar 24, 2015 · 13 comments
Milestone

Comments

@saschazelzer
Copy link

Hi,

is it possible to specify command line arguments or something equivalent in the asciidoc file when running ditaa? I would like to control effects like box shadows and box separations which is possible via ditaa command line arguments --no-separation and --no-shadows.

Thanks.

@pepijnve
Copy link
Member

No that's not yet possible, but shouldn't be too hard to add. I propose adding support for passing ditaa command line arguments as block attributes. For instance:

[ditaa,no-shadows, round-corners]
...

@pepijnve pepijnve added this to the 1.3.0 milestone Mar 24, 2015
@pepijnve
Copy link
Member

Resolved by 887a577
I ended up adding support for an options attribute that takes the ditaa command line arguments as value. You can write, for instance,

[ditaa, options="--no-shadows --scale 2.5 --round-corner"]

@saschazelzer
Copy link
Author

Awesome, thanks!

However, the image caching mechanism seems to be too aggressive now. Changing the options without changing the ascii image does not regenerate it. Is there some work-around?

@pepijnve
Copy link
Member

Thanks for catching that one. The options are indeed not taken into account for the cache validation. Oversight on my part. I'll try to fix that this evening.

@pepijnve pepijnve reopened this Mar 27, 2015
@pepijnve
Copy link
Member

5149ac6 makes the ditaa processor take the options attribute into account when deciding if the image needs to be regenerated or not.

@mojavelinux
Copy link
Member

I'm definitely in support of this approach, but I wonder if we should also have the option of making these customizations globally using document attributes. wdyt? Something like:

:ditaa-options: no-shadows,round-corners

or even

:ditaa-option-no-shadows:
:ditaa-option-round-corners:

@pepijnve
Copy link
Member

Sounds like a good idea. My first implementation actually had the options in the form you're using above; without the double-dashes. That looked more asciidoc-like in my eyes than raw command line arguments. I backed away from that approach thinking that it might be easier for users (and less documentation work) if you could just use the command line arguments of the tool in question as is.
That idea doesn't work 100% though since only a subset of the options are supported so I probably still have to document this anyway.

If we go ahead with the above syntax then the same syntax should be supported on the blocks themselves imo.
So you could either do

:ditaa-options: no-shadows, round-corners, scale=2.5

globally or

[ditaa, options="no-shadows,round-corners,scale=2.5"]

at the block level.

@saschazelzer any preference from your side? Make it look asciidoc-ish or stick with the raw command line options?

@mojavelinux
Copy link
Member

I like what you've suggested, esp the document level attribute.

@saschazelzer
Copy link
Author

I would definitely use document attributes if they were available. As a consequence, the syntax should be the same at the block level, as you already said. Your example above looks good to me. I am not an expert asciidoc user (yet) though.

@pepijnve
Copy link
Member

pepijnve commented Apr 4, 2015

Reopening for syntax change and document attribute support

@pepijnve pepijnve reopened this Apr 4, 2015
@pepijnve
Copy link
Member

pepijnve commented Apr 4, 2015

I ended up implementing the following:

  • The Ditaa extension supports the options scale, antialias, separation, round-corners, shadows and debug
  • Options can be specified per block as <option>=<value> or globally as a document attribute of the form :ditaa-option-<option>: <value>
  • Block level options override global options
  • Default values are Ditaa's defaults

The semantics of the options are

  • scale: scale factor specified as a decimal number (e.g. scale=1.5)
  • antialias: true to enable antialiasing; false to disable it
  • separation: true to leave spacing between adjacent blocks; false to remove it
  • round-corners: true to force round corners everywhere; false to use corner style from diagram
  • shadows: true to enable drop shadows; false to disable them
  • debug: true to display a debug grid in the diagram; false to remove it

@pepijnve pepijnve closed this as completed Apr 4, 2015
@mojavelinux
Copy link
Member

Huge 👍 !

@saschazelzer
Copy link
Author

This is great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants