nichtich / ditaa-markdown

process ditaa diagrams embedded in pandoc markdown
68 stars 7 forks source link

Passing Options to ditaa on a per image basis? #2

Closed dsanson closed 12 years ago

dsanson commented 12 years ago

Often in the same document I like to have both diagrams with --no-separation and diagrams with separation. So it would be nice to be able to pass options to ditaa on a per image basis.

In my fork, I've implemented this by allowing {.ditaa <opts>}, and passing the <opts> on to ditaa. Not sure that is the best solution, but it seems to work okay.

I don't know how to go about making this compatible with the other suggestion, of allowing alt text to occur after the .ditaa. Perhaps something like this: {.ditaa "Alt Text" <opts>}. Or maybe just treat anything after .ditaa up to the first word beginning with a - as the alt text, and everything from then on as options?

nichtich commented 12 years ago

Alt text and ditaa options should be supported, but I am not sure about the best syntax yet. The markdow should not lead to errors if processed without the ditaa-markdown filter. Just allowing arbitrary text will make the source a custom non-compatible variant of markdown. At least ditaa options can be supported similar to the existing .numberLines feature. At least this works, even with the scale option:

~~~~ {.ditaa .no-separation .no-shadows .scale:0.4}

We could support image captions similar to table captions:

~~~~ {.ditaa}
...
~~~~

Figure: Hello world

would become

![Hello World](image-1.pdf "Hello world") 
nichtich commented 12 years ago

I merged your fork and modified the syntax as described above.

dsanson commented 12 years ago

Nice! Good point about compatibility. And much more elegant code than my kludgy perl :-)

On Thu, Jan 19, 2012 at 5:26 AM, Jakob Voss reply@reply.github.com wrote:

I merged your fork and modified the syntax as described above.


Reply to this email directly or view it on GitHub: https://github.com/nichtich/ditaa-markdown/issues/2#issuecomment-3560714

nichtich commented 12 years ago

Well, the Perl code is just a hacked prototype anyway. I stable solution would be written in Haskell ;-)