asciidoctor / asciidoctor-kroki

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

Implement the kroki-default-options logic in the Ruby library #156

Open ggrossetie opened 3 years ago

ggrossetie commented 3 years ago

Currently, this feature is only available in JavaScript:

https://github.com/Mogztter/asciidoctor-kroki/blob/bca1ec83711989b0b1318222843eeac341e22c40/src/asciidoctor-kroki.js#L37-L59

edl7878 commented 3 years ago

Can we use kroki in asciidoctor binary?

Use it in asciidoctor.js is cool. I'd say, use kroki with vscode-asciidoctor, the experience is fabulous.

But when you use hugo with asciidoc, you need asciidoctor to render adoc files, at this time, if you want diagram, you can't use kroki, because there is no kroki plugin with asciidoctor binary.

Is it possible to use it with asciidoctor?

ggrossetie commented 3 years ago

Can we use kroki in asciidoctor binary?

Do you mean with the Asciidoctor (Ruby) CLI? If so, I need to document it but you can use the --require (or -r) to require the Ruby library:

$ gem install asciidoctor-kroki
$ asciidoctor -r asciidoctor-kroki doc.adoc

The JavaScript and Ruby implementation have a few differences but we are trying to fill the gap.

But when you use hugo with asciidoc, you need asciidoctor to render adoc files, at this time, if you want diagram, you can't use kroki, because there is no kroki plugin with asciidoctor binary.

Reading Hugo documentation, I think you should add asciidoctor-kroki in extensions: https://gohugo.io/content-management/formats/#external-helper-asciidoctor

If it's working we should probably update the documentation to state that asciidoctor-kroki is a possible value.

edl7878 commented 3 years ago

Checked the Hugo doc, asciidoctor-kroki not in the possible extensions of hugo, for now.

A proposal has been raised:

https://github.com/gohugoio/hugo/issues/7911

edl7878 commented 3 years ago

I have made a PR of hugo which tries to make asciidoctor-kroki a possible extension.

https://github.com/gohugoio/hugo/pull/7919

Or, you can build the PR yourself for instant use of asciidoctor-kroki with hugo right now, below just the hugo serve output:

INFO 2020/11/02 13:39:14 Rendering \c.adoc with C:\Ruby27-x64\bin\asciidoctor.bat using asciidoctor args [-r asciidoctor-html5s -r asciidoctor-kroki -a data-uri=1 -a kroki-server-url=https://XXX.com --base-dir C:\Users\roger\n\hugo\hugoTestSite\content -a outdir=C:\hugoTestSite\public\c --no-header-footer -] ...

Part of rendered page:

image

ggrossetie commented 3 years ago

Thanks @edl7878 :tada:

I've created https://github.com/Mogztter/asciidoctor-kroki/issues/166 to document how to use the Ruby library. We could probably also explain how to integrate it in Hugo once your pull request is merged. Feel free to add a comment in #166.

edl7878 commented 3 years ago

Yes, if the pull request is merged, then the workflow is flawless, and I will explain how to integrate it in Hugo.