Allow us to specify command line options within the diagram
dunkelziffer opened this issue · comments
A common use case for D2 is inline usage within Markdown. But we can't set CLI params there. It's actually possible in AsciiDoc:
[d2,layout=elk,theme=aubergine]
....
# diagram here
....
However, Markdown is much more widespread and only supports the D2 default layout and theme to my knowledge. I guess we would need an extension for the Markdown block syntax here. That's pretty unlikely to happen. So it would be nice to be able to do something like this:
```d2
layout: elk
theme: everglade-green
sketch: true
# diagram here
```
To reduce the number of used keywords (which could also break existing diagrams), you could nest these options, e.g.
```d2
d2_options: {
layout: elk
theme: everglade-green
sketch: true
}
# diagram here
```
You would have to decide, which options take precedence if a value is specified in both places. I'm not sure, which way around would be better. But as the layout engines support a slightly different feature set, my guess would be that it's smarter to give priority to the inline definition within the diagram so the diagrams become more self-contained.