felixvanoost / jekyll-kroki Goto Github PK
View Code? Open in Web Editor NEWA Jekyll plugin to convert diagram descriptions into images using Kroki
License: MIT License
A Jekyll plugin to convert diagram descriptions into images using Kroki
License: MIT License
When running jekyll-kroki
on a site that contains Jekyll posts, the diagram descriptions in the post Markdown files are not rendered as images:
Diagram description:
```plantuml
skinparam dpi 125
skinparam packageTitleAlignment left
rectangle "Main" {
(main.view)
(singleton)
}
rectangle "Base" {
(base.component)
(component)
(model)
}
rectangle "<b>main.ts</b>" as main_ts
(component) ..> (base.component)
main_ts ==> (main.view)
(main.view) --> (component)
(main.view) ...> (singleton)
(singleton) ---> (model)
```
Rendered HTML:
<pre><code class="language-plantuml">skinparam ranksep 20
skinparam dpi 125
skinparam packageTitleAlignment left
rectangle "Main" {
(main.view)
(singleton)
}
rectangle "Base" {
(base.component)
(component)
(model)
}
rectangle "<b>main.ts</b>" as main_ts
(component) ..> (base.component)
main_ts ==> (main.view)
(main.view) --> (component)
(main.view) ...> (singleton)
(singleton) ---> (model)
</code></pre>
jekyll-kroki
should render diagrams in all Jekyll document types.
Use a persistent HTTP connection when communicating with the Kroki server to reduce the likelihood of overloading very small self-hosted Kroki instances.
Run jekyll-kroki
using a Jekyll post_render
hook for the entire site instead of using the hook for each page / document. This would reduce some request overhead (e.g. finding the supported diagram languages) by handling all the rendering and embedding in a single step.
Simplify the naming of the configuration options from:
jekyll-kroki:
kroki_url: "https://my-kroki.server"
to:
kroki:
url: "https://my-kroki.server"
Attempt to sanitize the SVGs received from the Kroki server to mitigate some of the potential security vulnerabilities associated with embedding SVG blocks in HTML files.
Allow the URL of the Kroki instance to be specified in the Jekyll configuration file _config.yml
and fall back to the default public server https://kroki.io if the specified URL is not provided.
This would allow the use of private Kroki servers to prevent the risk of leaking sensitive data.
jekyll-kroki
returns with an exit code of 0 (success) after an error occurs, leading any upstream scripts that originally called the Jekyll command to ignore the error.
For instance, with the Kroki URL set to https://expired.badssl.com/
:
[jekyll-kroki] "SSL_connect returned=1 errno=0 state=error: certificate verify failed (certificate has expired)" in 'render_diagram' on line 76 of /workspaces/jekyll-kroki/lib/jekyll/kroki.rb
$ echo $?
0
Handle retries in HTTP requests to improve the robustness of the plugin.
Hi,
i can't get it to work with graphviz.
here is the relevant part of my file:
'''plantuml
participant Jekyll
participant Kroki #MediumSpringGreen
Jekyll -> Kroki: Encoded diagram description
Kroki --> Jekyll: Rendered diagram in SVG format
'''
'''graphviz
digraph "test" {
a -> b
}
'''
i replaced the backticks ` with the ' because otherwise github issues messes the rendering up.
i get the following log:
[jekyll-kroki] Rendered 1 diagrams using Kroki instance at 'https://kroki.io/'
done in 0.784 seconds.
the plantuml part is rendered correctly, the graphviz part isn't rendered at all. i only see the plaintext.
I'm not sure if i'm doing something wrong or if this is a bug.
When attempting to render diagrams using a private Kroki instance that has an SSL certificate error (in this case, the certificate has expired), jekyll-kroki
fails with the following stack trace:
[jekyll-kroki] Rendering diagrams using Kroki instance at '<REDACTED>'
------------------------------------------------
Jekyll 4.3.2 Please append `--trace` to the `build` command
for any additional information or backtrace.
------------------------------------------------
/usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:108:in `rescue in get_supported_languages': undefined method `[]' for nil:NilClass (NoMethodError)
raise e.response[:body]
^^^^^^^
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:105:in `get_supported_languages'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:46:in `embed_page'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:35:in `block in embed_site'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:31:in `each'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:31:in `embed_site'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:155:in `block in <top (required)>'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/hooks.rb:103:in `block in trigger'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/hooks.rb:102:in `each'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/hooks.rb:102:in `trigger'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/site.rb:213:in `render'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/site.rb:80:in `process'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/command.rb:28:in `process_site'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:65:in `build'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:36:in `process'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `each'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
from /usr/local/bundle/gems/jekyll-4.3.2/exe/jekyll:15:in `<top (required)>'
from /usr/local/bundle/bin/jekyll:25:in `load'
from /usr/local/bundle/bin/jekyll:25:in `<top (required)>'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli/exec.rb:58:in `load'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli/exec.rb:58:in `kernel_load'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli/exec.rb:23:in `run'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli.rb:492:in `exec'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli.rb:34:in `dispatch'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli.rb:28:in `start'
from /usr/local/bundle/gems/bundler-2.4.21/exe/bundle:37:in `block in <top (required)>'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
from /usr/local/bundle/gems/bundler-2.4.21/exe/bundle:29:in `<top (required)>'
from /usr/local/bundle/bin/bundle:25:in `load'
from /usr/local/bundle/bin/bundle:25:in `<main>'
/usr/local/lib/ruby/3.2.0/net/protocol.rb:46:in `connect_nonblock': SSL_connect returned=1 errno=0 peeraddr=172.17.0.20:8000 state=error: certificate verify failed (certificate has expired) (Faraday::SSLError)
from /usr/local/lib/ruby/3.2.0/net/protocol.rb:46:in `ssl_socket_connect'
from /usr/local/lib/ruby/3.2.0/net/http.rb:1342:in `connect'
from /usr/local/lib/ruby/3.2.0/net/http.rb:1248:in `do_start'
from /usr/local/lib/ruby/3.2.0/net/http.rb:1237:in `start'
from /usr/local/bundle/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:112:in `request_with_wrapped_block'
from /usr/local/bundle/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:102:in `perform_request'
from /usr/local/bundle/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:66:in `block in call'
from /usr/local/bundle/gems/faraday-2.7.11/lib/faraday/adapter.rb:45:in `connection'
from /usr/local/bundle/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:65:in `call'
from /usr/local/bundle/gems/faraday-2.7.11/lib/faraday/middleware.rb:17:in `call'
from /usr/local/bundle/gems/faraday-2.7.11/lib/faraday/middleware.rb:17:in `call'
from /usr/local/bundle/gems/faraday-retry-2.2.0/lib/faraday/retry/middleware.rb:153:in `call'
from /usr/local/bundle/gems/faraday-2.7.11/lib/faraday/rack_builder.rb:153:in `build_response'
from /usr/local/bundle/gems/faraday-2.7.11/lib/faraday/connection.rb:444:in `run_request'
from /usr/local/bundle/gems/faraday-2.7.11/lib/faraday/connection.rb:200:in `get'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:106:in `get_supported_languages'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:46:in `embed_page'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:35:in `block in embed_site'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:31:in `each'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:31:in `embed_site'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:155:in `block in <top (required)>'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/hooks.rb:103:in `block in trigger'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/hooks.rb:102:in `each'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/hooks.rb:102:in `trigger'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/site.rb:213:in `render'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/site.rb:80:in `process'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/command.rb:28:in `process_site'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:65:in `build'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:36:in `process'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `each'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
from /usr/local/bundle/gems/jekyll-4.3.2/exe/jekyll:15:in `<top (required)>'
from /usr/local/bundle/bin/jekyll:25:in `load'
from /usr/local/bundle/bin/jekyll:25:in `<top (required)>'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli/exec.rb:58:in `load'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli/exec.rb:58:in `kernel_load'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli/exec.rb:23:in `run'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli.rb:492:in `exec'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli.rb:34:in `dispatch'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli.rb:28:in `start'
from /usr/local/bundle/gems/bundler-2.4.21/exe/bundle:37:in `block in <top (required)>'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
from /usr/local/bundle/gems/bundler-2.4.21/exe/bundle:29:in `<top (required)>'
from /usr/local/bundle/bin/bundle:25:in `load'
from /usr/local/bundle/bin/bundle:25:in `<main>'
/usr/local/lib/ruby/3.2.0/net/protocol.rb:46:in `connect_nonblock': SSL_connect returned=1 errno=0 peeraddr=172.17.0.20:8000 state=error: certificate verify failed (certificate has expired) (OpenSSL::SSL::SSLError)
from /usr/local/lib/ruby/3.2.0/net/protocol.rb:46:in `ssl_socket_connect'
from /usr/local/lib/ruby/3.2.0/net/http.rb:1342:in `connect'
from /usr/local/lib/ruby/3.2.0/net/http.rb:1248:in `do_start'
from /usr/local/lib/ruby/3.2.0/net/http.rb:1237:in `start'
from /usr/local/bundle/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:112:in `request_with_wrapped_block'
from /usr/local/bundle/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:102:in `perform_request'
from /usr/local/bundle/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:66:in `block in call'
from /usr/local/bundle/gems/faraday-2.7.11/lib/faraday/adapter.rb:45:in `connection'
from /usr/local/bundle/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:65:in `call'
from /usr/local/bundle/gems/faraday-2.7.11/lib/faraday/middleware.rb:17:in `call'
from /usr/local/bundle/gems/faraday-2.7.11/lib/faraday/middleware.rb:17:in `call'
from /usr/local/bundle/gems/faraday-retry-2.2.0/lib/faraday/retry/middleware.rb:153:in `call'
from /usr/local/bundle/gems/faraday-2.7.11/lib/faraday/rack_builder.rb:153:in `build_response'
from /usr/local/bundle/gems/faraday-2.7.11/lib/faraday/connection.rb:444:in `run_request'
from /usr/local/bundle/gems/faraday-2.7.11/lib/faraday/connection.rb:200:in `get'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:106:in `get_supported_languages'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:46:in `embed_page'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:35:in `block in embed_site'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:31:in `each'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:31:in `embed_site'
from /usr/local/bundle/gems/jekyll-kroki-0.2.1/lib/jekyll/kroki.rb:155:in `block in <top (required)>'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/hooks.rb:103:in `block in trigger'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/hooks.rb:102:in `each'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/hooks.rb:102:in `trigger'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/site.rb:213:in `render'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/site.rb:80:in `process'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/command.rb:28:in `process_site'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:65:in `build'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:36:in `process'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `each'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
from /usr/local/bundle/gems/jekyll-4.3.2/exe/jekyll:15:in `<top (required)>'
from /usr/local/bundle/bin/jekyll:25:in `load'
from /usr/local/bundle/bin/jekyll:25:in `<top (required)>'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli/exec.rb:58:in `load'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli/exec.rb:58:in `kernel_load'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli/exec.rb:23:in `run'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli.rb:492:in `exec'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli.rb:34:in `dispatch'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/cli.rb:28:in `start'
from /usr/local/bundle/gems/bundler-2.4.21/exe/bundle:37:in `block in <top (required)>'
from /usr/local/bundle/gems/bundler-2.4.21/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
from /usr/local/bundle/gems/bundler-2.4.21/exe/bundle:29:in `<top (required)>'
from /usr/local/bundle/bin/bundle:25:in `load'
from /usr/local/bundle/bin/bundle:25:in `<main>'
The Faraday::SSLError
exception should be handled by displaying the corresponding error message.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.