terrastruct / d2

D2 is a modern diagram scripting language that turns text to diagrams.
https://d2lang.com
Mozilla Public License 2.0
16.18k stars 401 forks source link

`d2 play input.d2` #1213

Open alixander opened 1 year ago

alixander commented 1 year ago

What if this command just encoded the input.d2 file and opened it up on playground?

bo-ku-ra commented 1 year ago

for what purpose?

my idea is https://play.d2lang.com/?l=&script=qlDQtVOo5AIEAAD__w%3D%3D& Export=SVG

foobar.d2 xy{ icon:https://play.d2lang.com/?l=&script=qlDQtVOo5AIEAAD__w%3D%3D&Export=SVG }

alixander commented 1 year ago

@bo-ku-ra it's kind of hidden right now, but you can do this:

https://api.d2lang.com/render/svg?script=SspX0NVVyC4FkUWJXIAAAAD__w==&layout=dagre&theme=7&sketch=1

https://play.d2lang.com/?l=&script=qtADBZmVQkZJSUGxlb5-YkGmXopRTmJeul5yfq5-USpIp35xWbp9cXJRZkGJbXBxQYSBX1hYpbOJW3ZouFeEp6Ojo6NLfHy5ra1aTmJlfmmJbUpielGqWklGam6qrblacXZqSXKGrSEXIAAA__8%3D&sketch=1&theme=7&

danielsitnik commented 4 months ago

Sorry to revive this topic, but If anyone is interested, the content you see in the script parameter in the URL of the playground is just the diagram code after being compressed with Deflate and than base64url encoded.

Please note that it uses base64url (eg: / is converted to _ and = to %3d) and not plain base64. 😉