asciidoctor / asciidoctor-kroki

Asciidoctor.js extension to convert diagrams to images using Kroki!
https://kroki.io/
MIT License
155 stars 52 forks source link

How to save png files locally? #365

Closed ivanmanning closed 2 years ago

ivanmanning commented 2 years ago

Hi,

On the documentation page, it says that by default, Asciidoctor Kroki generates a link, to a Kroki server or a local file. To change the default for SVG diagrams, set the kroki-default-options attribute.

So, how can I make it to save the images locally, and use that image instead of the link to the Kroki server? Thanks.

Here is my test example:

= BOOK title
:chapter: 6
:sectnums:
:figure-caption: {chapter}.
:listing-caption: {chapter}.
:table-caption: {chapter}.
:leveloffset: 1
:imagesoutdir: E:\images\test
:kroki-default-options: inline

= CHAPTER title

Diagram test

[graphviz, "abcd-flowchart", svg]
----
digraph G { rankdir=LR; Graphviz->AsciiDoc->HTML}
----

And this is the command I'm using to create XML file:

asciidoctor -r asciidoctor-kroki -b docbook test.adoc

And this is the result I get:

<?xml version="1.0" encoding="UTF-8"?>
<?asciidoc-toc?>
<?asciidoc-numbered?>
<article xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en">
<info>
<title>BOOK title</title>
<date>2022-04-29</date>
</info>
<section xml:id="_chapter_title">
<title>CHAPTER title</title>
<simpara>Diagram test</simpara>
<informalfigure role="kroki">
<mediaobject>
<imageobject>
<imagedata fileref="https://kroki.io/graphviz/svg/eNpLyUwvSizIUHBXqFYoSszLTskssvUJslZwB4mWZVbp2jkWJ2dmuuQn69p5hPj61AIArUgQ9Q=="/>
</imageobject>
<textobject><phrase>abcd-flowchart</phrase></textobject>
</mediaobject>
</informalfigure>
</section>
</article>
ggrossetie commented 2 years ago

This feature is not implemented in the Ruby extension, see: https://github.com/Mogztter/asciidoctor-kroki/issues/156

ivanmanning commented 2 years ago

Thank you for your reply, I appreciate it. Do you have in plan to implement it? And when?

ggrossetie commented 2 years ago

I don't have time right now but feel free to submit a pull request.

ivanmanning commented 2 years ago

I'd love to but I'm not a Ruby developer

ggrossetie commented 2 years ago

I wasn't either before I start contributing to Asciidoctor. That's a good opportunity to learn a new language!