Giter Site home page Giter Site logo

asciidoctor / asciidoctor-kroki Goto Github PK

View Code? Open in Web Editor NEW
144.0 7.0 46.0 2.13 MB

Asciidoctor.js extension to convert diagrams to images using Kroki!

Home Page: https://kroki.io/

License: MIT License

JavaScript 76.50% Shell 0.17% HTML 0.35% Ruby 22.99%
asciidoctor extension diagram javascript kroki plantuml ditaa uml graphviz mermaid

asciidoctor-kroki's Introduction

🖍 Asciidoctor Kroki Extension

Build JavaScript Build JavaScript npm version Gem version Zulip Chat

An extension for Asciidoctor.js to convert diagrams to images using Kroki!

Install

Node.js

Install the dependencies:

$ npm i asciidoctor asciidoctor-kroki

Create a file named kroki.js with following content and run it:

const asciidoctor = require('@asciidoctor/core')()
const kroki = require('asciidoctor-kroki')

const input = 'plantuml::hello.puml[svg,role=sequence]'

kroki.register(asciidoctor.Extensions) // <1>
console.log(asciidoctor.convert(input, { safe: 'safe' }))

const registry = asciidoctor.Extensions.create()
kroki.register(registry) // <2>
console.log(asciidoctor.convert(input, { safe: 'safe', extension_registry: registry }))

<1> Register the extension in the global registry
<2> Register the extension in a dedicated registry

Browser

Install the dependencies:

$ npm i asciidoctor asciidoctor-kroki

Create a file named kroki.html with the following content and open it in your browser:

<html lang="en">
  <head>
    <title>Asciidoctor x Kroki</title>
    <meta charset="utf-8">
    <script src="node_modules/@asciidoctor/core/dist/browser/asciidoctor.js"></script>
    <script src="node_modules/asciidoctor-kroki/dist/browser/asciidoctor-kroki.js"></script>
  </head>
  <body>
    <div id="content"></div>
    <script>
      const input = `Let's take an example with a _GraphViz_ "Hello World":

[graphviz]
....
digraph G {
  Hello->World
}
....`

      const asciidoctor = Asciidoctor()

      const registry = asciidoctor.Extensions.create()
      AsciidoctorKroki.register(registry) // <1>
      const result = asciidoctor.convert(input, { safe: 'safe', extension_registry: registry })
      document.getElementById('content').innerHTML = result
    </script>
  </body>
</html>

<1> Register the extension in a dedicated registry

❗ IMPORTANT: If you want to reference a diagram file in a browser environment you will need to define the base directory using the base_dir option. In addition, you will also need to provide an implementation to read a binary file synchronously for a given path. You can find an implementation based on XMLHttpRequest in the source code: https://github.com/ggrossetie/asciidoctor-kroki/blob/9585b969014a1894d0c9fb76df10e1e8c66ce2b2/test/browser/test.js#L2-L34. Once httpGet is defined, here's how we should configure the extension:

const registry = asciidoctor.Extensions.create()
AsciidoctorKroki.register(registry, {
  vfs: {
    read: (path, encoding = 'utf8') => httpGet(path, encoding),
    exists: (_) => false,
    add: (_) => { /* no-op */ }
  }
})
const input = 'plantuml::hello.puml[svg,role=sequence]'
asciidoctor.convert(input, { safe: 'safe', base_dir: window.location.origin, extension_registry: registry })

Ruby

Install the dependency:

$ gem install asciidoctor-kroki

Require the library using the --require (or -r) option from the Asciidoctor CLI:

$ asciidoctor -r asciidoctor-kroki doc.adoc

Antora Integration

If you are using Antora, you can integrate Kroki in your documentation site.

  1. Install the extension in your playbook project:

    $ npm i asciidoctor-kroki
    
  2. Register the extension in your playbook file:

    asciidoc:
      extensions:
        - asciidoctor-kroki

    https://docs.antora.org/antora/2.3/playbook/configure-asciidoc/#extensions

  3. Enjoy!

💡 TIP: You can use the kroki-fetch-diagram option to download the images from Kroki at build time. In other words, while viewing pages you won't rely on Kroki anymore. However, in Antora, this is not currently compatible with inline SVG images.

asciidoc:
  attributes:
    kroki-fetch-diagram: true

Usage

In your AsciiDoc document, you can either write your diagram inline or, alternatively, you can make a reference to the diagram file using macro form or with the include directive.

Here's an example where we declare a GraphViz diagram directly in our AsciiDoc document using the block syntax:

[graphviz]
....
digraph foo {
  node [style=rounded]
  node1 [shape=box]
  node2 [fillcolor=yellow, style="rounded,filled", shape=diamond]
  node3 [shape=record, label="{ a | b | c }"]

  node1 -> node2 -> node3
}
....

GraphViz diagram

In the example below, we are using the vegalite macro to reference a file named chart.vlite:

vegalite::chart.vlite[svg,role=chart,opts=interactive]

Vega-Lite chart diagram

Finally, we can use the include directive to reference a diagram file:

[plantuml,alice-bob,svg,role=sequence]
....
include::alice-bob.puml[]
....

PlantUML diagram

References and includes with Antora

If you use this Asciidoctor Kroki Extension in combination with Antora, all references and includes MUST use Antora Resource IDs. The .puml-files are best placed in the partials-directory of the modules.

Block macros

vegalite::partial$chart.vlite[svg,role=chart,opts=interactive]

Includes

[plantuml,alice-bob,svg,role=sequence]
----
include::partial$alice-bob.puml[]
----

Syntax

You can declare positional and named attributes when using the block or the macro form.

Positional attributes

When using the block form:

  1. The first positional attribute specifies the diagram type (see below for a complete list).
  2. The second optional positional attribute assigns a file name (i.e. target) to the generated diagram. Currently, the value of this attribute is ignored, and an auto-generated hash will be used as file name for caching purposes (see #48).
  3. The third optional positional attribute specifies the image format.

Example:

[mermaid,abcd-flowchart,svg]
....
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
....

In the above example, the diagram type is mermaid, the file name (i.e. target) is abcd-flowchart, and the image format is svg.

When using the macro form:

  1. The first optional positional attribute specifies the image format.

Example:

vegalite::chart.vlite[svg]

In the above example, the diagram type is vegalite, the target is chart.vlite, and the image format is svg.

Named attributes

You can also use both positional and named attributes. Here's an example:

.PlantUML example
[plantuml#diagAliceBob,alice-and-bob,svg,role=sequence]
....
alice -> bob
....

As you can see, we specified an id using the syntax #diagAliceBob just after the diagram type, and we are also using a named attribute to assign a role using role=sequence.

Here's another example using the macro form:

vegalite::chart.vlite[svg,role=chart,opts=interactive]

We are using a positional attribute to declare the image format and two named attributes to define the role and options.

Attributes

It's important to note that not all attributes are used in all converters. Here's a list of all attributes used in the built-in HTML 5 converter:

  • target
  • width
  • height
  • format (default svg)
  • fallback
  • link
  • float
  • align
  • role
  • title (used to define an alternative text description of the diagram)

Options

In addition, the following options are available when using the SVG format:

  • inline
  • interactive
  • none (used for cancelling defaults)

Options can be defined using options attribute (or opts for short):

[blockdiag,opts=inline]
....
blockdiag {
  Kroki -> generates -> "Block diagrams";

  Kroki [color = "greenyellow"];
  "Block diagrams" [color = "pink"];
}
....

Supported diagram types

Kroki currently supports the following diagram libraries:

Each diagram libraries support one or more output formats. Consult the Kroki documentation to find out which formats are supported.

Configuration

Attribute name Description Default value
kroki-server-url The URL of the Kroki server (see "Using Your Own Kroki") https://kroki.io
kroki-fetch-diagram Define if we should download (and save on the disk) the images from the Kroki server.
This feature is not available when running in the browser.
false
kroki-http-method Define how we should get the image from the Kroki server. Possible values:
  • get: always use GET requests
  • post: always use POST requests
  • adaptive: use a POST request if the URI length is longer than kroki-max-uri-length (default 4000) characters, otherwise use a GET request
adaptive
kroki-plantuml-include A file that will be included at the top of all PlantUML diagrams as if !include file was used. This can be useful when you want to define a common skin for all your diagrams. The value can be a path or a URL.
kroki-plantuml-include-paths Search path(s) that will be used to resolve !include file additionally to current diagram directory, similar to PlantUML property plantuml.include.path. Please use directory delimiter ; (Windows) or : (Unix) for multiple paths, e.g.: "c:/docu/styles;c:/docu/library" or "~/docu/styles:~/docu/library"
kroki-max-uri-length Define the max URI length before using a POST request when using adaptive HTTP method (kroki-http-method) 4000

❗ IMPORTANT: kroki-fetch-diagram and kroki-plantuml-include are only available when safe mode is server or lower. If you want to learn more about Asciidoctor safe modes: https://docs.asciidoctor.org/asciidoctor/latest/safe-modes/

Default configuration

By default, images are generated as SVG when possible. To alter this, set the kroki-default-format attribute:

:kroki-default-format: png

You can unset this with :kroki-default-format!: or :kroki-default-format: svg.

ℹ️ NOTE: An AsciiDoc attribute can be defined through the CLI or API, in the document’s header or in the document’s body. In addition, if you are using Antora, you can define AsciiDoc attributes in your playbook and/or in your component descriptor.

References:

For instance, in an Antora playbook or component descriptor:

asciidoc:
  attributes:
    kroki-default-format: png@

(the @ allows the attribute value to be reset in documents)

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.

:kroki-default-options: inline

You can unset this with :kroki-default-options: none or :kroki-default-options!: or specify opts=none in a block or macro.

Preprocessing

Some diagram libraries allow referencing external entities by URL or accessing resources from the filesystem. For example PlantUML allows the !import directive to pull fragments from the filesystem or a remote URL or the standard library. Similarly, Vega-Lite can load data from a URL using the url property.

By default, the Kroki server is running in SECURE mode which restrict access to files on the file system and on the network.

For ease of use and convenience, Asciidoctor Kroki will try to resolve and load external resources before sending a request to the Kroki server. This feature is only available when Asciidoctor safe mode is server or lower.

Using Your Own Kroki

By default, this extension sends information and receives diagrams back from https://kroki.io.

You may choose to use your own server due to:

  • Network restrictions - if Kroki is not available behind your corporate firewall
  • Network latency - you are far from the European public instance
  • Privacy - you don't want to send your diagrams to a remote server on the internet

This is done using the kroki-server-url attribute. Typically, this is at the top of the document (under the title):

:kroki-server-url: http://my-server-url:port

For instance, if you have followed the instructions to set up a self-managed server using Docker you can use the following:

:kroki-server-url: http://localhost:8080

Note that either the http:// or https:// prefix is required (the default Docker image only uses http).

You can also set this attribute using the Javascript API, for instance:

asciidoctor.convertFile('file.adoc', { safe: 'safe', attributes: { 'kroki-server-url': 'http://my-server-url:port' } })

Contributing

Setup

To build this project, you will need the latest active LTS of Node.js and npm (we recommend nvm to manage multiple active Node.js versions).

The current latest Node LTS version is: v14.15.x

Please use latest npm version v7.x to generate lockfile using v2 format (i.e., "lockfileVersion": 2), see lockfileversion

Update NPM @ Linux

npm i -g npm

Update NPM @ Windows

  1. Open PowerShell as Administrator selecting Run as Administrator

  2. Install npm-windows-upgrade

     Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
     npm install --global --production npm-windows-upgrade
    
  3. Upgrade npm

     npm-windows-upgrade
    

Reference: npm-windows-upgrade

Building

  1. Install the dependencies:

    $ npm i
    
  2. Generate a distribution:

    $ npm run dist
    

When working on a new feature or when fixing a bug, make sure to run the linter and the tests suite:

$ npm run lint
$ npm run test

asciidoctor-kroki's People

Contributors

ahus1 avatar akosma avatar anb0s avatar bobzomer avatar brendanhaines avatar bwalding avatar ccantill avatar danyill avatar demagnevalcegelec avatar dependabot-preview[bot] avatar dependabot[bot] avatar digitalmoksha avatar djencks avatar ggrossetie avatar jagedn avatar jkblskw avatar juracy avatar lomax avatar marcelstoer avatar mcbeelen avatar mijlouis avatar mojavelinux avatar mwabik avatar stenzengel avatar sturtison avatar xavier-calland avatar zebreus avatar zeldigas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

asciidoctor-kroki's Issues

Support separate but local data files via data.url property for Vega-Lite

Thank you very much for supporting Vega and Vega-Lite. I works nicely.

I have a specific request regarding the location of the visualized data:

I prefer keeping the visualized data in a separate and local local file (instead of inlined in the diagram specification) via the "data.url" property (https://vega.github.io/vega-lite/docs/data.html#url), because it can be smaller (e.g. CSV instead JSON), can be edited easier, there is a better separation of concerns....

Example:
I prefer

{
	"data": {
		"url": "data.csv"
	}
}

over

{
	"data": {
		"values": [
			{
				"a": "2020-01-05",
				"b": 0.3,
				"c": "C1"
			},
			{
				"a": "2020-01-15",
				"b": 0.7,
				"c": "C1"
			}
		]
	}
}

A separate data file is currently not possible with "asciidoctor-kroki" (It works when using Vega-Lite directly.), because an error is created:

Skipping vegalite block macro. No such file: https://kroki.io/vegalite/svg/....

I suppose, that the reason for this error is, that the referenced file containing the data (i.e. "data.csv") is not uploaded to kroki. One "workaround" could therefore be to make "data.csv" publicly available:

{
	"data": {
		"url": "http://.../data.csv"
	}
}

But this does not work either (It works when using Vega-Lite directly, i.e. without "asciidoctor-kroki"). Even if this remote URL would work, it would have the disadvantage the file must be available before the asciidoctor generation with :kroki-fetch-diagram: true.

I created a public repo where you can find all three variants:
https://gitlab.com/winni/asciidoctor-kroki-vegalite

The generated result can be found here:
https://winni.gitlab.io/asciidoctor-kroki-vegalite/test.html

I don't know if there is a feasible solution to support local data files and how much effort it would be to implement.

Perhaps the "workaround" with remote URLs can be implemented easily (or could it cause a security problem)?

I don't know if this is a very special use case in combination with Vega-Lite, or if this or similar requirements would make sense for other types of diagrams.

What do you think?

[kroki-fetch-diagram] cannot find module 'mkdirp'

I've installed asciidoctor-kroki in node.js (windows) together with reveal.js. I set the attribute :kroki-fetch-diagram: true to fetch the diagram during convert to have the presentation for offline usage later. I've registered it with own convert-slides.js:

// Load Asciidoctor.js and the reveal.js converter
var asciidoctor = require('@asciidoctor/core')()
var asciidoctorRevealjs = require('@asciidoctor/reveal.js')
asciidoctorRevealjs.register()

// Load asciidoctor-kroki
var kroki = require('asciidoctor-kroki')
kroki.register(asciidoctor.Extensions)

// Convert the document 'presentation.adoc' using the reveal.js converter
var options = { safe: 'unsafe', backend: 'revealjs' }
asciidoctor.convertFile('presentation.adoc', options)

Now it coplains aboud missing dependency

Skipping plantuml block. Cannot find module 'mkdirp'
Require stack:
- d:\Project\docu\node_modules\asciidoctor-kroki\dist\node\node-fs.js
- d:\Project\docu\node_modules\asciidoctor-kroki\dist\node\fetch.js
- d:\Project\docu\node_modules\asciidoctor-kroki\dist\node\asciidoctor-kroki.js
- d:\Project\docu\convert-slides.js

Add configuration to disable fallback to https://kroki.io

Story:
As an architect/developer
I want to disable the fallback to https://kroki.io via configuration
So that we don't share sensitive diagrams with Intellectual Property content with any 3rd party like kroki.io and always use our own instance running the eyuzutech/kroki container.

Scenario - Configuration
When the asciidoctor-kroki plugin is loaded
Then it takes into account a new fallback configuration key which allows to disable the fallback to https://kroki.io

Scenario - Default Configuration is Enabled
When the asciidoctor-kroki plugin is loaded
Then the default fallback configuration is enabled
And the diagram generation falls back to https://kroki.io

Scenario - Configuration is Disabled
When the asciidoctor-kroki plugin is loaded
And the fallback configuration is disabled
Then the diagram generation does not fall back to any default URL

Support workspace as base directory as configuration/fallback

Since Asciidoctor VSCode extension support workspace as root directory in the setting "asciidoc.useWorkspaceRoot": true.
It will be nice, if asciidoctor-kroki support workspace as base directory by configuration or workspace folder as fallback?

Path resolution incorrect if no output directory specified

I'm looking at updating the vscode extension to the latest version of asciidoctor-kroki as part of asciidoctor/asciidoctor-vscode#301

My working document is (say) here:

/media/mulhollandd/KINGSTON/operating_information/Operating_Information/architecture/Operating_Information_Architecture.adoc

and the document sets:

:imagesdir: media
:kroki-server-url: https://kroki.io
:kroki-fetch-diagram:

The extension does set the base_dir API option but not imagesoutdir, outdir, to_dir or base_dir document attributes as appear to be expected in fetch.js:

https://github.com/Mogztter/asciidoctor-kroki/blob/f9b9abfb64be2339bde78bb77c41339e88dfcbfd/src/fetch.js#L5-L9

Under these circumstances, my images turn up in /home/mulhollandd/media/ which surprised me no end and it was only looking through the code which made me look 😉

The cause is fs.writeFileSync in:

https://github.com/Mogztter/asciidoctor-kroki/blob/f9b9abfb64be2339bde78bb77c41339e88dfcbfd/src/node-fs.js#L7-L12

where filePath might be something like media/ba38556d595f9b57735747d9de9ee77e7335cdb2.svg.

The node fs module which uses the fs.openSync on this relative path and somewhat deep in node internals it appears that if there is only a relative path then perhaps it uses the user's home directory (or perhaps this is what vs code is using as the cwd, although I doubt it). The node filesystem docs don't help me very much.

I think the problem is that the asciidoctor-kroki extension is incorrectly handling base_dir which is an API option, not a document attribute. Perhaps we should be using instead the document attribute docdir?

https://asciidoctor.org/docs/user-manual/#piping-content-through-the-cli

Looking at the (Ruby) code:

https://github.com/asciidoctor/asciidoctor/blob/8f838709af08cdd5c3f1c91e4a6bba54e87cca54/lib/asciidoctor/convert.rb#L12-L20

It would seem that if docdir is used then it is set base on base_dir if it is specified.

https://github.com/asciidoctor/asciidoctor/blob/88bc891d6a0143f3a2142f41d29cabe3cb21fe3f/lib/asciidoctor/document.rb#L380-L390

So I think the correct fix would be to replace baseDir with docDir along the lines of:

  const imagesOutputDir = doc.getAttribute('imagesoutdir')
  const outDir = doc.getAttribute('outdir')
  const toDir = doc.getAttribute('to_dir')
  const docDir = doc.getAttribute('docdir') || ''
  const imagesDir = doc.getAttribute('imagesdir') || ''
  let dirPath
  if (imagesOutputDir) {
    dirPath = imagesOutputDir
  } else if (outDir) {
    dirPath = path.join(outDir, imagesDir)
  } else if (toDir) {
    dirPath = path.join(toDir, imagesDir)
  } else {
    dirPath = path.join(docDir, imagesDir)
  }

but I haven't entirely convinced myself so I haven't submitted a PR.

Thoughts?

Macro form appears not to read files correctly

I can't currently get the macro form to function correctly.

For the asciidoc syntax:

plantuml::test.puml[]

I get an error in my rendered HTML:

ENOENT: no such file or directory, open 'test.puml' - plantuml::test.puml[]

I looked at:

https://github.com/Mogztter/asciidoctor-kroki/blob/1daf269b6524a1ad42793ca9f26430db34405b43/src/asciidoctor-kroki.js#L136-L142

When I look in the debugger at vfs.read(target) I see that
we have target = test.puml and this doesn't exist where it is being read from (probably the directory the process is being executed from which in this case may not be the same folder the source file is in).

Perhaps all we want is: parent.getDocument().normalizeSystemPath('test.puml') which seems what is done in (random example): https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/b848e53b5a23134348ac40741a3d777fcb22c684/lib/implicit-header-include-processor/extension.rb#L8-L10

Create more similar HTML compared to asciidoctor-diagram (src, alt, width and height attributes of img element)

When I switched from asciidoctor to asciidoctor.js, I found out that
asciidoctor-diagram and asciidoctor-kroki (with "kroki-fetch-diagram":
true) do not produce the same HTML output (e.g. for plantuml diagrams):

Asciidoc Source:

[plantuml,my-filename]
----
...
---

Generated HTML with asciidoctor (Ruby) and asciidoctor-diagram:

<div class="imageblock">
<div class="content">
<img src="images/my-filename.png" alt="my filename" width="117" height="132">
</div>

Generated HTML with asciidoctor.js and asciidoctor-kroki:

<div class="imageblock kroki">
<div class="content">
<img src="images/c124036f4dade706bedfd3445ad534c857d766fa.svg" alt="my-filename">
</div>

There are several differences:

  1. asciidoctor-diagram uses the second argument "my-filename" for the file name in the "src" attribute: "images/my-filename.png". Kroki generates a unique ID.
  2. asciidoctor-diagram replaces the "-" character in "my-filename" with " " in the "alt" attribute. Kroki does no replace this character.
  3. asciidoctor-diagram sets the image "width" and "height" on the element. Kroki does not set these attributes.
  4. asciidoctor-diagram uses the "png" format by default. Kroki uses the "svg" format.

Would it be possible to make the results more similar (perhaps with the exception SVG vs. PNG) in order to facilitate the transition between the two extensions?

Allow to control image alignment when generating an image block

For instance, the following should center the image:

[nomnoml,align="center"]
....
[Pirate|eyeCount: Int|raid();pillage()|
  [beard]--[parrot]
  [beard]-:>[foul mouth]
]

[<abstract>Marauder]<:--[Pirate]
[Pirate]- 0..7[mischief]
[jollyness]->[Pirate]
[jollyness]->[rum]
[jollyness]->[singing]
[Pirate]-> *[rum|tastiness: Int|swig()]
[Pirate]->[singing]
[singing]<->[rum]
....

'npm run test' failed @ windows

I've tried the Contributing description @ Windows 10 with fresh clone and versions:

Executed:

  • npm install
  • npm run lint (see #67 )
  • npm run test --> failed:
$ npm run test

> [email protected] test C:\Users\kenobi\dev\asciidoctor-kroki
> npm run test:node && npm run test:browser

> [email protected] test:node C:\Users\kenobi\dev\asciidoctor-kroki
> mocha test/*.js

  preprocessVegaLite
    √ should throw an error for invalid JSON
    √ should return original diagramText for valid JSON but without "data.url"
    √ should throw an error for unexisting local file referenced with relative path
    √ should throw an error for unexisting local file referenced with "file://"
Skipping preprocessing of Vega-Lite view specification, because reading the referenced remote file 'https://raw.githubusercontent.com/Mogztter/asciidoctor-kroki/master/unexisting.csv' caused an error:
Error: No such file: https://raw.githubusercontent.com/Mogztter/asciidoctor-kroki/master/unexisting.csv
    √ should warn and return original diagramText for unexisting remote file referenced with "data.url", because it can perhaps be found by kroki server (354ms)
    1) should return diagramText with inlined local file referenced with "data.url"
    √ should return diagramText with inlined remote file referenced with "data.url" (355ms)

  Registration
    √ should register the extension

  Conversion
    When extension is registered
      √ should convert a diagram to an image (45ms)
      2) should convert a diagram with an absolute path to an image
      3) should convert a diagram with a relative path to an image
      √ should download and save an image to a local folder (353ms)
      √ should apply substitutions in diagram block
      4) should apply attributes substitution in target
      √ should not download twice the same image (322ms)
      √ should create a literal block when format is txt (285ms)
      √ should read diagram text
      √ should embed an SVG image with built-in allow-uri-read and data-uri (available in Asciidoctor.js 2+) (1034ms)
      √ should inline an SVG image with built-in allow-uri-read (available in Asciidoctor.js 2+) (369ms)
      √ should inline an SVG image with kroki-fetch-diagram (952ms)
      √ should include an interactive SVG image with built-in allow-uri-read and data-uri (available in Asciidoctor.js 2+) (1049ms)
      5) should include an interactive SVG image with kroki-fetch-diagram
      √ should convert a PacketDiag diagram to an image
      √ should convert a RackDiag diagram to an image
      √ should convert a Vega diagram to an image
      √ should convert a Vega-Lite diagram to an image
      6) should inline a referenced data file for a Vega-Lite diagram and convert to an image
      √ should convert a WaveDrom diagram to an image
      √ should convert a BPMN diagram to an image
      √ should convert a Bytefield diagram to an image

Implement a cache to fetch an image from the server only when the content has changed

The filename of the image can be defined by the user. In this case, we cannot tell if we need to fetch the image again because the content has changed or if we don't because the content is the same.

Previously, we were using the md5sum of the diagram content as filename.
We might need to write a metadata file next to the images to compare the md5sum.

Switch to POST if the URI is too long

When using very large Vega specification file (when data is embed in the file), the public instance of Kroki can return the following error "414 Request-URI Too Large nginx/1.14.0 (Ubuntu)".

I think we should use a POST request to avoid this error if the URI is longer than 4096.

See: yuzutech/kroki-go#11

Consider supporting xref like syntax in diagrams, translated to diagram specific syntax

This may be mostly useful in Antora.
Many types of diagrams, in particular plantuml, support linking from svg diagram elements to elsewhere.
The idea, which Ec Roc thought of, is to allow specifying these links using xref-like syntax, and translating them into the diagram specific syntax.
Since this is kroki I propose calling them 'kref'.
I've implemented a prototype of this as a standalone project, https://gitlab.com/djencks/asciidoctor-antora-kref, but it might make sense to integrate this into asciidoctor-kroki so the block/block macro can communicate the diagram type to the 'kref' inline macro so the desired format does not need to be further specified.
Since I don't have any idea what interpretation or translation of 'xref' syntax might be appropriate outside Antora, I've started by only registering the kref inline macro when Antora is present.

[kroki-fetch-diagram] generated-file-name parameter not used

see #47 for my setup

My test presentation.adoc sets the imagesdir and use generated-file-name parameter to have all images with human readable names:

ifndef::imagesdir[:imagesdir: ./images]

== UML class diagram test with kroki
[plantuml, "diagram-classes", svg]
....
class BlockProcessor
class DiagramBlock
class DitaaBlock
class PlantUmlBlock

BlockProcessor <|-- DiagramBlock
DiagramBlock <|-- DitaaBlock
DiagramBlock <|-- PlantUmlBlock
....

It fetches the diagram and writes to images/210a0ebf2a7bb40669c4e3c895b2c9396f048327.svg instead of images/diagram-classes.svg like ascidoctor-diagram does.

It would be good to support the mandatory diagram parameters from asciidoctor-diagram.

Local data file that is referenced relatively in Vega-Lite file is looked up relatively to the Asciidoctor file

A local data file (see #53) that is referenced relatively in a Vega-Lite file is looked up relatively to the Asciidoctor file in "asciidoctor-kroki". This works differently and more logically in "asciidoctor-diagram", where the Vega-Lite file is used as origin.

Example:

test.adoc:

= Test
:kroki-fetch-diagram: true

vegalite::subdir/test.vl[]

subdir/test.vl:

{
	"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
	"data": {
		"url": "test.csv"
	},
	"encoding": {
		"x": {
			"field": "a",
			"type": "ordinal"
		},
		"y": {
			"field": "b",
			"type": "quantitative"
		}
	},
	"mark": "bar"
}

subdir/test.csv:

a,b
A,2.1
B,1.2
C,0.3

Current behavior:

Skipping vegalite block macro. Preprocessing of Vega-Lite view specification failed, because reading the referenced local file 'test.csv' caused an error:
Error: ENOENT: no such file or directory, open 'test.csv'

Expected behavior:

The CSV data file should be looked up relativ to the JSON file and no error should occur.

Workarounds:

  • Put test.csv in the same directory as the asciidoc file
  • Add relative path from asciidoc file : e.g. "url": "subdir/test.csv"
  • Reference test.csv absolutely: e.g. "url": "C:\\...\\subdir\\test.csv"

All workarounds work with "asciidoctor-kroki" but seem to break "asciidoctor-diagram".

@Mogztter What would be the best way to fix this problem? If you have an idea, I could provide a pull request.

How to generate Image at build time

I use Asciidoctor with jruby and I'd like to have my images generated a build time instead of calling kroki web server later.
I've try to add the following atgtribute in the adoc file :

  • :kroki-default-options: inline
  • :kroki-fetch-diagram: true
    to have the image result generate during the build and having the image either in a folder or in the resulting html, but none of them append, I still got a link to the kroki web server
    What attribute should I set and how should I define them ?

Allow to configure the criticality when an include is missing

We might want to introduce an attribute to control the criticality when an include is missing:

kroki-plantuml-unresolved-local-include

  • warn: log a warning
  • error: throw an exception
  • ignore (or suppress): silently ignore

We could do the same for remote include. The default value of local include would be error and the default value for remote include would be warn.

Follow-up #141

asciidoctor: FAILED: 'asciidoctor-kroki' could not be loaded

I have a project where I want to render asciidoc inline svgbob using Kroki.
I added gem 'asciidoctor-kroki' to my Gemfile.
I have done bundle install successfully but when I run my project with the following command :

asciidoctor -r asciidoctor-kroki *.adoc -D public --trace

I have this result :

LoadError: no such file to load -- asciidoctor-kroki
     require at org/jruby/RubyKernel.java:974
     require at /opt/jruby/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54
      parse! at /usr/local/bundle/gems/asciidoctor-2.0.10/lib/asciidoctor/cli/options.rb:276
        each at org/jruby/RubyArray.java:1809
      parse! at /usr/local/bundle/gems/asciidoctor-2.0.10/lib/asciidoctor/cli/options.rb:274
      parse! at /usr/local/bundle/gems/asciidoctor-2.0.10/lib/asciidoctor/cli/options.rb:34
  initialize at /usr/local/bundle/gems/asciidoctor-2.0.10/lib/asciidoctor/cli/invoker.rb:24
      <main> at /usr/local/bundle/gems/asciidoctor-2.0.10/bin/asciidoctor:13
        load at org/jruby/RubyKernel.java:1009
      <main> at /usr/local/bundle/bin/asciidoctor:23

Document the macro form

Currently we don't document the macro form for use with asciidoctor-kroki and initially I thought it wasn't supported based on the README.

Looking through the tests I joyfully realise it is indeed possible!

plantuml::${file}[svg,role=sequence]
vegalite::test/fixtures/chart.vlite[svg,role=chart]
bytefield::test/fixtures/simple.bytefield[svg,role=bytefield,opts=inline]
vegalite::test/fixtures/chart.vlite[svg,role=chart,opts=interactive]

I'll do a PR for this at some stage.

Support plantuml-config-attribute for site-wide includes

The asciidoctor-plantuml-extension had a very cool option plantuml-config-file that allowed default-includes for all diagrams, so that they had the same design.

I'm aware of the plantuml-server include version, but I especially liked that the config could be checked in together with the document and that each document was able to define their own config without needing access to the server.

Could we implement such an options for Kroki?

Pass "all" the attributes defined on the block to the Image node

Currently, we create a new JSON object and we selectively add attributes: https://github.com/Mogztter/asciidoctor-kroki/blob/51a3c2e9d66b6886093aa1c9a43d7b03683a6c2e/src/asciidoctor-kroki.js#L63-L67

As a result, some important attributes are missing:

  • align
  • width
  • height
  • format
  • fallback
  • float
  • ...

The user could also define custom attributes that could be used in a custom template/converter.

We should try to get closer to the original implementation: https://github.com/asciidoctor/asciidoctor-diagram/blob/66876e9c11c401eec943ff6968cd0c5f6c443906/lib/asciidoctor-diagram/diagram_processor.rb#L61

A few things we should do:

  • Use the original attributes but
    • Extract (ie. remove from the original attributes) title and caption.
    • Update target attribute accordingly
    • Set alt attribute
  • Use $assign_caption to assign the caption on the image block (currently this method is not mapped in Asciidoctor.js)

Sporadic "Unexpected end of JSON input" for vega-lite diagram

Sometimes, (I could not find the cause) there is an error "Unexpected end of JSON input" for vega-lite files. It seems to correlate with the length of the file, but even setting :kroki-http-method: post did not solve the problem. I'm not sure if it is really a length problem. Perhaps it is some concurrency problem or vega-lite problem or even a local problem?

Can you reproduce the problem?

Example (somewhat lengthy, but this seems to be have impact):

= Test
:kroki-fetch-diagram:

[vegalite]
....
{
	"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
	"data": {
		"values": [
			{
				"a": "B",
				"b": 1.2
			},
			{
				"a": "B",
				"b": 1.2
			},
			{
				"a": "B",
				"b": 1.2
			},
			{
				"a": "B",
				"b": 1.2
			},
			{
				"a": "B",
				"b": 1.2
			},
			{
				"a": "A",
				"b": 2.1
			},
			{
				"a": "B",
				"b": 1.2
			},
			{
				"a": "A",
				"b": 2.1
			},
			{
				"a": "B",
				"b": 1.2
			},
			{
				"a": "A",
				"b": 2.1
			},
			{
				"a": "B",
				"b": 1.2
			},
			{
				"a": "A",
				"b": 2.1
			},
			{
				"a": "B",
				"b": 1.2
			},
			{
				"a": "A",
				"b": 2.1
			},
			{
				"a": "B",
				"b": 1.2
			},
			{
				"a": "A",
				"b": 2.1
			},
			{
				"a": "B",
				"b": 1.2
			},
			{
				"a": "A",
				"b": 2.1
			},
			{
				"a": "B",
				"b": 1.2
			},
			{
				"a": "A",
				"b": 2.1
			},
			{
				"a": "B",
				"b": 1.2
			},
			{
				"a": "C",
				"b": 0.3
			}
		]
	},
	"encoding": {
		"x": {
			"field": "a",
			"type": "ordinal"
		},
		"y": {
			"field": "b",
			"type": "quantitative"
		}
	},
	"mark": "bar"
}
....

Current behavior:

Skipping vegalite block. GET https://kroki.io/vegalite/svg/eNrtk7EOgjAQhuf2KczFUVtFJzf1MYzDIRWqBRSORkN4d9uCidHVxMWl6X_5_u-mazmDcX3IVI6wGkFGdKlXUlqVokg1ZU0sdCl7IEynRpOSdilOdVnAxNUTJN9tOWNg0TSqdmnnEvMjNwzmjWd9il2ai8iHbvJ7av1KRWL-d_1d33RtX6mZWATKPXseYFDFoUx0kT4v6DZ8GBy1MolXYK8Aul-Uz2XlCmiAD_vg_tmJ3zrXBgvShKStCsVhfY7VOfBYAe8emR-p3Q== - error; reason: Unexpected end of JSON input

Some remarks:

  • :kroki-http-method: post does not solve the problem.
  • Removing some values in the data property helps sometimes.
  • Even if there is the described error, the diagram seems to be correct sometimes.

Very strange! Do you have an idea, how to narrow down the problem?

why not supporting all of kroki supported format?

Hi,

first, thank you for your work in the asciidoc community.

I have a maybe dumb question: why asciidoctor-kroki is not supporting all of kroki's supported formats?

I did a dirty test: in my vscode extension that uses asciidoctor-kroki, if I patch asciidoctor-kroki.js line 16588 by adding vega and vegalite, these 2 formats now work in the asciidoctor preview (tuned to use an onprem kroki)

Any reason to not activate these formats? known bug?

Again, thanks a lot for your asciidoctor work (gitlab support, kroki, browser extension, ...)

happy easter!

[proposal] Add a sample project to bootstrap antora integration.

It may be easier to users to startup with antora + kroki by cloning sample repository.
Similar to one existed for my deprecated ascidoctor-plantuml extension.

I am ready to create a new repo for this and contribute it together with documentation updates.

Document configuration options

Bits and pieces I learned in discussions that should be documented:

General diagram options

here: https://github.com/asciidoctor/asciidoctor-diagram
we are trying to stay compatible with Asciidoctor diagram

please note that diagram attributes are not supported since the Kroki API does not support specific attributes: https://github.com/asciidoctor/asciidoctor-diagram#diagram-attributes

All Asciidoctor Kroki parameters

Besides kroki-server-url and kroki-fetch-diagram there are probably others?

Leverage Antora cache to locally cache images

Antora uses a cache directory to avoid fetching remote resources:

On subsequent runs, Antora will attempt to resolve remote resources from the cache instead.
https://docs.antora.org/antora/2.2/playbook/configure-runtime/#cache

Currently, the "cache" does not work with Antora because the output directory is deleted between runs.
What we should do:

  1. Resolve the cache directory from Antora
  2. Create a directory in the cache directory named kroki (for instance, if the cache directory is ./.cache/antora then we should create ./.cache/antora/kroki)
  3. When fetching images from the Kroki server, write them in the cache directory
  4. Copy them to the output directory

When running again we should check if the image exists in the cache directory, if that's the case we should copy the image into the output directory, if not we should fetch it.

Open questions

  • Should we include the diagram library version in the hash? If yes, how do we retrieve the current version of the diagram library from the server?
  • Can we fetch the images again when the Antora --fetch option is used? If not, how can we remove the images?

Prefix auto-generated image filenames with diag-

As pointed out in #48, asciidoctor-diagram prefixes auto-generated image filenames with diag-

I'd be keen to have the diag- prefix in asciidoctor-kroki as a way of namespacing the generated images which don't have an explicit filename (for instance useful if one wished to include in a .gitignore).

Antora does not support inline + kroki-fetch-diagram option

I think we should workaround this limitation otherwise an exception is thrown:

SecurityError: Jail is not an absolute path: modules/ROOT/pages/install
    at Opal.send (/nix/store/a3xmzr6d2lbl517gc53hy82jz0xzpjdv-antora-wrapper/libexec/antora-wrapper/node_modules/opal-runtime/src/opal.js:1660:19)
    at Function.$$exception (/nix/store/a3xmzr6d2lbl517gc53hy82jz0xzpjdv-antora-wrapper/libexec/antora-wrapper/node_modules/opal-runtime/src/opal.js:5519:14)
    at $PathResolver.$$raise (/nix/store/a3xmzr6d2lbl517gc53hy82jz0xzpjdv-antora-wrapper/libexec/antora-wrapper/node_modules/opal-runtime/src/opal.js:5204:31)
    at $PathResolver.$$system_path (/nix/store/a3xmzr6d2lbl517gc53hy82jz0xzpjdv-antora-wrapper/libexec/antora-wrapper/node_modules/asciidoctor.js/dist/node/asciidoctor.js:12144:18)
    at $Block.$$normalize_system_path (/nix/store/a3xmzr6d2lbl517gc53hy82jz0xzpjdv-antora-wrapper/libexec/antora-wrapper/node_modules/asciidoctor.js/dist/node/asciidoctor.js:4962:37)
    at $Block.$$read_contents (/nix/store/a3xmzr6d2lbl517gc53hy82jz0xzpjdv-antora-wrapper/libexec/antora-wrapper/node_modules/asciidoctor.js/dist/node/asciidoctor.js:5071:25)
    at Object.$$read_svg_contents (/nix/store/a3xmzr6d2lbl517gc53hy82jz0xzpjdv-antora-wrapper/libexec/antora-wrapper/node_modules/asciidoctor.js/dist/node/asciidoctor.js:17236:33)
    at Object.$$image (/nix/store/a3xmzr6d2lbl517gc53hy82jz0xzpjdv-antora-wrapper/libexec/antora-wrapper/node_modules/asciidoctor.js/dist/node/asciidoctor.js:16058:38)
    at Object.Opal.send (/nix/store/a3xmzr6d2lbl517gc53hy82jz0xzpjdv-antora-wrapper/libexec/antora-wrapper/node_modules/opal-runtime/src/opal.js:1660:19)
    at Object.convertImage (/nix/store/a3xmzr6d2lbl517gc53hy82jz0xzpjdv-antora-wrapper/libexec/antora-wrapper/node_modules/@antora/asciidoc-loader/lib/converter/html5.js:47:17)

The least worst solution is to pass the diagram as data-uri. It's not 100% accurate but it should work. Maybe we should add a warning message to let the user know?

[Antora+Kroki] Mermaid sequence diagramm no height/width

Hello, I wanted to use Antora with Kroki for a Mermaid sequence diagram.
It looks like that kroki, returns no sizes for this diagram type.
I tried out other diagrams with kroki which worked.
I tried out the kroki-fetch-diagram: true, which also did not work.
This might be related to yuzutech/kroki#151.

Example code of not working sequence diagram:

[mermaid,fetch-users]
....
sequenceDiagram;
    U->>K: A;
    activate K;
    K->>U: B;
    deactivate K;
    opt empty C;
        U->>P: D!;
        activate P;
        P->>U: E!;
        deactivate P;
    end;
    U->>PP: F;
    PP->>U: G;
....

Example code of working sequence diagram:

[mermaid,fetch-users]
....
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
....

Screenshot from the fetched image that has 0x0 size.
image

'npm run lint' failed @ windows

I've tried the Contributing description @ Windows 10 with fresh clone and versions:

npm i --> Works
npm run lint returns error:

> [email protected] lint C:\Users\user\dev\asciidoctor-kroki
> standard src/**.js test/**.js

Der Befehl "standard" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] lint: `standard src/**.js test/**.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

The german text says the command "standard" is wrong or cannot be found.

Document how to use with Antora

This looks like a real gem 💎 !

But how do you use it with Antora? I installed Antora with npm and have been happily running antora antora-playbook.yml so far. What do I need to change to have something simple as

[plantuml,alice-bob,svg,role=sequence]
....
alice -> bob
....

inside an .adoc rendered as a diagram?

Errors, warnings and failures in browser example

(I start by confessing I know little about browserify or javascript in browsers in general)

When I try to use the macro form from a browser as per the README:

<html>
  <head>
    <script src="node_modules/@asciidoctor/core/dist/browser/asciidoctor.js"></script>
    <script src="node_modules/asciidoctor-kroki/dist/browser/asciidoctor-kroki.js"></script>
  </head>
  <body>
    <div id="content"></div>
    <script>
      var input = 'plantuml::hello.puml[svg,role=sequence]'

      var asciidoctor = Asciidoctor()
      var kroki = AsciidoctorKroki

      const registry = asciidoctor.Extensions.create()
      kroki.register(registry)
      var result = asciidoctor.convert(input, {'extension_registry': registry})
      document.getElementById('content').innerHTML = result
    </script>
  </body>
</html>

I receive the following error in the browser window:

fs.readFileSync is not a function - plantuml::hello.puml[]

I think readFileSync does not exist because it is specifically excluded (quite likely for good reasons, but then the wrong example to choose maybe?)

https://github.com/Mogztter/asciidoctor-kroki/blob/982d016dd89d811d88fa1b73ec40bb40020a3e89/package.json#L17

I removed the exclude for node-fs which allowed processing to continue but then I received an asciidoctor.js warning suggesting I had sinned by not specifying an absolute path.

Fair enough, but plantuml::hello.puml[] doesn't work and neither does plantuml::file:///home/mulhollandd/Documents/test-kroki/hello.puml[svg,role=sequence].

In my console window, I have the following error message:

SecurityError: Jail is not an absolute path: . asciidoctor.js:413:20
    Error self-hosted:891
    constructor file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:413
    $Exception_new$1 file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:4939
    send file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:1674
    $$exception file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:4965
    $$raise file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:4653
    $$system_path file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:32604
    $$normalize_system_path file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:25244
    normalizeSystemPath file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:42403
    diagramBlockMacro file:///home/mulhollandd/Documents/test-kroki/node_modules/asciidoctor-kroki/dist/browser/asciidoctor-kroki.js:18981
    apply file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:45476
    $$instance_exec file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:3818
    send file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:1674
    $$19 file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:39343
    send file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:1674
    $$process file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:39347
    $$call file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:17847
    send file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:1674
    alias file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:1864
    $$next_block file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:29760
    $$next_section file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:29476
    $$parse file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:29134
    $$parse file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:27594
    doc file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:35875
    $$load file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:35876
    $$convert file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:36016
    convert file:///home/mulhollandd/Documents/test-kroki/node_modules/@asciidoctor/core/dist/browser/asciidoctor.js:41454
    <anonymous> file:///home/mulhollandd/Documents/test-kroki/test1.html:36

I may be going down a rabbit hole but I expect it to be an educational rabbit hole.

Also while I'm there, should our html be just a little more correct to avoid browser warnings?

<!DOCTYPE html>
  <head>
    <meta charset="utf-8">

I think for the example to work it should be more an inline diagram at the moment.

PlantUML !include preprocessor?

I'm using lot of !include files in PlantUML diagrams to have clear sturcture and DRY.

== UML class diagram test with kroki
[plantuml, "diagram-classes", svg]
....
!include <src/style-presets.iuml>

class BlockProcessor
class DiagramBlock
class DitaaBlock
class PlantUmlBlock

BlockProcessor <|-- DiagramBlock
DiagramBlock <|-- DitaaBlock
DiagramBlock <|-- PlantUmlBlock
....

For local builds with plantuml.jar it works, but with remote server like PlantUML server or kroki it does not work. I understand that it is not wanted, because it will do preprocessing with knowlegde of PlantUML syntax and has to be updated etc.

Is there other solution to solve similar structural problems at client side?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.