Skip to content

Commit a463fc8

Browse files
yetibot-mps[bot]Yetibot
andauthored
Fix output format for SVG-only diagram types (Excalidraw, BPMN, SvgBob, etc.) (#7)
Co-authored-by: Yetibot <yetibot@yetibot.com>
1 parent c135d20 commit a463fc8

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/yetibot_kroki/commands/kroki.clj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@
1616
(string/replace "+" "-")
1717
(string/replace "/" "_")))
1818

19+
(def svg-only-types
20+
#{"bpmn" "bytefield" "excalidraw" "nomnoml" "pikchr" "svgbob" "wavedrom"})
21+
1922
(defn kroki-url
2023
[type graph]
21-
(str "https://kroki.io/" type "/png/" (encode-for-kroki graph)))
24+
(let [format (if (contains? svg-only-types (string/lower-case type)) "svg" "png")]
25+
(str "https://kroki.io/" type "/" format "/" (encode-for-kroki graph))))
2226

2327
(defn graphviz-url
2428
[graphviz]

test/yetibot_kroki/commands/kroki_test.clj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@
4545
=> (str "https://kroki.io/mermaid/png/" (encode-for-kroki "graph TD; A-->B;"))
4646

4747
(kroki-url "graphviz" "digraph G {}")
48-
=> (str "https://kroki.io/graphviz/png/" (encode-for-kroki "digraph G {}")))
48+
=> (str "https://kroki.io/graphviz/png/" (encode-for-kroki "digraph G {}"))
49+
50+
(kroki-url "excalidraw" "{\"type\": \"excalidraw\"}")
51+
=> (str "https://kroki.io/excalidraw/svg/" (encode-for-kroki "{\"type\": \"excalidraw\"}"))
52+
53+
(kroki-url "BPMN" "bpmn content")
54+
=> (str "https://kroki.io/BPMN/svg/" (encode-for-kroki "bpmn content")))
4955

5056
(fact
5157
"kroki-cmd handles valid, invalid, and multiline diagrams"

0 commit comments

Comments
 (0)