Is anyone using Kroki pack?

I am using @Federico.Stefanato 's Kroki pack. I’m a little unsure how insert the markup for the diagram in the formula. I see the syntax argument, but, that’s really unwieldy to maintain. This might be a ridiculously basic question, but can I set it as a variable from a code block?

Kinda like

nwdiag {
  network dmz {
    address = "210.x.x.x/24"

    web01 [address = "210.x.x.1"];
    web02 [address = "210.x.x.2"];
  }
  network internal {
    address = "172.x.x.x/24";

    web01 [address = "172.x.x.1"];
    web02 [address = "172.x.x.2"];
    db01;
    db02;
  }
}

And then reference it something like this:

Kroki::GetDiagram(
‘nwdiag’, $kroki-diagram,
outputType: “svg”,
transparentBackground: False()
)

I tried a few different ways and could figure it out. Any help is appreciated.

Hi @Brian_Morin!

I’m not so sure if the problem resides in how you reference the variable.

Kroki::GetDiagram('nwdiag', 'nwdiag {
  network dmz {
    address = "210.x.x.x/24"

    web01 [address = "210.x.x.1"];
    web02 [address = "210.x.x.2"];
  }
  network internal {
    address = "172.x.x.x/24";

    web01 [address = "172.x.x.1"];
    web02 [address = "172.x.x.2"];
    db01;
    db02;
  }
}')

This should work.

Also, If you want to extrapolate the code into a different variable

//f_SyntaxCode - named variable (note the quotes, if its a literal like in this case)
'nwdiag {
  network dmz {
    address = "210.x.x.x/24"

    web01 [address = "210.x.x.1"];
    web02 [address = "210.x.x.2"];
  }
  network internal {
    address = "172.x.x.x/24";

    web01 [address = "172.x.x.1"];
    web02 [address = "172.x.x.2"];
    db01;
    db02;
  }
}'

And then

Kroki::GetDiagram('nwdiag', f_SyntaxCode)

I hope it helps. Please, tell me otherwise :slight_smile:

1 Like

Thank you for the answer, however I think I need to learn more Coda basics, because I can’t figure out how to set the variable like you have. If you could point me to the docs that cover that, I’d appreciate it.

Setting f_SyntaxCode like you’re referencing is a mystery to me so far.


Ah. I think I understand more now. I made a table with 1 line, a name and diagram column, then tried to reference the second column, it’s not working yet, but I think I’m on the right path.

I’d still like to find a primer on how variables like this work, if you have time.

HA! figured it out, Thank you Frederico!

1 Like

Hey @Brian_Morin,
Happy that eventually you figured it out!

Most of the times, it’s great idea to use columns as reference data as you did.

Sometimes however, you’ll find convenient having named formulas acting as global variables (i.e. at document scope) that you can refer within any other formula.

Enjoy Coda! :wink:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.