Skip to content

Commit

Permalink
resolves #392 add support for diagramsnet (#393)
Browse files Browse the repository at this point in the history
resolves #392 

Co-authored-by: Jakob Liskow <[email protected]>
  • Loading branch information
JkbLskw and Jakob Liskow authored Sep 14, 2022
1 parent e7da296 commit 059510b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ Kroki currently supports the following diagram libraries:
* [Vega-Lite](https://github.com/vega/vega-lite): `vegalite`
* [WaveDrom](https://github.com/wavedrom/wavedrom): `wavedrom`
* [Structurizr](https://github.com/structurizr/dsl): `structurizr`
* [Diagrams.net](https://github.com/jgraph/drawio): `diagramsnet` _(only available via [Using Your Own Kroki](#using-your-own-kroki "Using Your Own Kroki"))_

Each diagram libraries support one or more output formats.
Consult the [Kroki documentation](https://kroki.io/#support) to find out which formats are supported.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ module Kroki
vegalite
wavedrom
structurizr
diagramsnet
].freeze
end

Expand Down
2 changes: 1 addition & 1 deletion ruby/spec/asciidoctor_kroki_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
describe ::AsciidoctorExtensions::Kroki do
it 'should return the list of supported diagrams' do
diagram_names = ::AsciidoctorExtensions::Kroki::SUPPORTED_DIAGRAM_NAMES
expect(diagram_names).to include('vegalite', 'plantuml', 'bytefield', 'bpmn', 'excalidraw', 'wavedrom', 'pikchr', 'structurizr')
expect(diagram_names).to include('vegalite', 'plantuml', 'bytefield', 'bpmn', 'excalidraw', 'wavedrom', 'pikchr', 'structurizr', 'diagramsnet')
end
it 'should register the extension for the list of supported diagrams' do
doc = Asciidoctor::Document.new
Expand Down
3 changes: 2 additions & 1 deletion src/asciidoctor-kroki.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ module.exports.register = function register (registry, context = {}) {
'vega',
'vegalite',
'wavedrom',
'structurizr'
'structurizr',
'diagramsnet'
]
if (typeof registry.register === 'function') {
registry.register(function () {
Expand Down
30 changes: 30 additions & 0 deletions test/test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('Registration', () => {
expect(registry['$registered_for_block_macro?']('excalidraw')).to.be.an('object')
expect(registry['$registered_for_block_macro?']('pikchr')).to.be.an('object')
expect(registry['$registered_for_block_macro?']('structurizr')).to.be.an('object')
expect(registry['$registered_for_block_macro?']('diagramsnet')).to.be.an('object')
})
})

Expand Down Expand Up @@ -1043,6 +1044,35 @@ line up $r*0.45 right $r*0.45 then right
expect(html).to.contain('https://kroki.io/pikchr/svg/eNptUk1T2zAQvetX7Jgww0cxisEUZ6aHdoYbNzjkwEW2lVhF0TLyJqL_vispSV3g4NFo3-rt2_c88_ADZFkZJ6xx2qs-3b_XFzOfKsHkSlULcQJPpDyBcj1o_lqL3esoTkSL71BoqzfaUQEt2h5WhtJ76DE4qOUprDxuwKqRuOG9HIPokSAOrCLaoUXPjKp7FUu5SI2lhks4k-XNN3kulPcYJiTxNSEspdjgToM364Hgpmx4kygn6q5PgWsVHytj7YG82ZMHuPqKfNlE2qPOIOLez4OGjTIO_NZqoEERrFGPMJJXaTANHrfrIVOMySVmWRlnxuFgELa_dUdXvY5lMugKMKSs6aJZwJTz-fX8DoL6A62moLXj7ZLZy2avMC7c_KdWflSbxT7-_PXwuEhyeXx-kC2a-X8vBx6R8plzvpx4rhz6BO6UhSJz8RkjzUwc2B58KRYvxRSqJGNp3TccP22Zm_KPkcdsHRkLesdzg6Eh2s-xzDynApD1bN--6krQJz-SE1FaqY97XMiyPjKl6_0Uu89yDthtPQVv64knfwGrmf6K')
expect(html).to.contain('<div class="imageblock kroki">')
})
it('should convert a Diagrams.net diagram to an image', () => {
const input = `
[diagramsnet]
....
<?xml version="1.0" encoding="UTF-8"?>
<mxfile host="Electron" modified="2022-09-13T07:43:35.176Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/20.2.8 Chrome/102.0.5005.167 Electron/19.0.15 Safari/537.36" etag="LhBTAD99BNPTPnW6KKtz" version="20.2.8" type="device">
<diagram id="ZahvhYCcWguJS4UQkUxV" name="Page-1">
<mxGraphModel dx="1104" dy="725" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="elJO9X42axDvzzEHx44D-1" value="" style="shape=step;perimeter=stepPerimeter;whiteSpace=wrap;html=1;fixedSize=1;" parent="1" vertex="1">
<mxGeometry x="340" y="160" width="140" height="30" as="geometry" />
</mxCell>
<mxCell id="elJO9X42axDvzzEHx44D-4" value="" style="shape=step;perimeter=stepPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rotation=-180;" parent="1" vertex="1">
<mxGeometry x="320" y="200" width="140" height="30" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
....
`
const registry = asciidoctor.Extensions.create()
asciidoctorKroki.register(registry)
const html = asciidoctor.convert(input, { extension_registry: registry })
expect(html).to.contain('https://kroki.io/diagramsnet/svg/eNq1VE1zmzAQvedXaHRKZmqQAGM7mGTy0SYTJ6k7duo2NxXWoIlAjKzY2L--Czj1dKY9tNOe2NVqP957K8bndaHIGsxK6jKm3GGUQJnoVJZZTJ_mH3pDen52NC7qpVRAcr2yMX2vILFGl5QUeHEpIY2pxzyvx0Y97s_Z4DTwT_2-wwfhMyUigxKT-g4jxwtZpnqzIo9zwpnDIoIHYRCROgxOyEVVKVjAt4m0bt8fOH5Ijie384f7d0TJFyA3kLzoE5IasXGkdj3meM6QXOVGF-By5jnM6TOGbcMBeRvR5SM85n0yE0th5L4uYrQC8d3nl_OL69Ho8nE6n5aLcDKxO3pgo-tAid1WENMU1jIBenZEyDiVIjOiIBKRP4t8nX-9ShbZ690sePr08lR_pqQUBeZMEXyPtzmYVdQ3RlT5g05BkbRGujkLKEm3MR14fUoy09TjnTGTOyzAUY_sVaawagNWa2Vl1TmJLktE2drCGOS1NZdadVUqbP7DmCVCHbyFTG0e06E36PxbkFneVOLhCFUVTRA7r3KBcjVmhwAxGK3tm9NCugKlWh7wvvvrSNvUtFvw-0ug7j6OvgSeqK_Xu9372zoIrpE6shbqFQfHYey2QYAzoRorC1VUgZEFWDCtO33zok0uLcwqkUC8QcKj3BYq5tFS1tDRyqPDRLwV3EIjBz2M1skFuFrWbAkG_QBnR6V4iN9Nxx9vzvI9dz7aAiXI9kk_I3U7qH-APfhf2I22wjYL3uND9jdMeB0THvsXTIzdw0o1scMTaV-au39q-A9yu5_Q2XelwGNC')
expect(html).to.contain('<div class="imageblock kroki">')
})
it('should convert a Vega-Lite diagram and resolve data.url relative to the diagram file', async () => {
const registry = asciidoctor.Extensions.create()
asciidoctorKroki.register(registry)
Expand Down

0 comments on commit 059510b

Please sign in to comment.