devilray

devilray

How can Kino be used to export a mermaid image in Livebook?

I have created a Livebook that pokes around a DNS zone, getting a list of subdomains, domain registration information, and records, particularly DMARC, SPF and DKIM records, to help quickly audit a domain’s health.

Once I generate this report, I would like to allow easy download of the report tables, as well as the Mermaid diagram presenting the information visually. Is there a way to use Kino to create a downloadable SVG, or even HTML page with the Mermaid SVG in it, to distribute to clients?

The repo with this Livebook in it is at GitHub - sachamasry/dns-zone-explorer: Elixir Livebook DNS zone exploration and auditing tool · GitHub.

I appreciate any help anyone can offer!

Marked As Solved

christhekeele

christhekeele

As far as I know, no—not without some work. The Mermaid renderer is client-side javascript, and the Kino cell implementation just sends its content straight to it without further interactivity/control. I think your options are to:

  1. Install the mermaid CLI onto the systems you are running livebook, shell out your diagrams to it, and download the result
  2. Implement your own custom JS-powered Kino, using Kino.Mermaid’s implementation as a starting point, and add download functionality to it
  3. Propose adding download functionality to the existing implementation in the issue tracker

If you do end up doing 2, definitely do 3 as well and submit a PR! I think it can be done entirely in the client, just by wrapping the SVG that gets rendered with a hover-state download button, that triggers a client-side download of the SVG in whatever format you had in mind.

Also Liked

devilray

devilray

Thank you @christhekeele, I thought this would be the case. I don’t have enough time to do this right now, but as I think it is useful—the diagram has been generated already, after all—I plan to come back to it and do (2) and (3) as you pointed out.

christhekeele

christhekeele

Submitted as a PR to Kino, with a download button, updated CSS, and caption support. If you want to give it a go, try using this in your livebook’s setup Mix.install:

{:kino, "~> 0.14.1", github: "christhekeele/kino", branch: "downloadable-mermaid"}
christhekeele

christhekeele

@devilray It got approved and merged into main, you should get downloads on all your mermaid diagrams next release of Kino! (Or on {:kino, "~> 0.14.1", github: "livebook-dev/kino"} of course)

Where Next?

Popular in Questions Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41989 114
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New

We're in Beta

About us Mission Statement