├── .asciidoctor
└── kroki
│ └── .gitkeep
├── .editorconfig
├── .gitattributes
├── .github
├── FUNDING.yml
└── workflows
│ ├── build-js.yml
│ ├── build-ruby.yml
│ ├── release-js.yml
│ └── release-ruby.yml
├── .gitignore
├── .mocharc.json
├── .vscode
├── launch.json
└── settings.json
├── LICENSE
├── README.md
├── RELEASE.md
├── dist
└── browser
│ └── asciidoctor-kroki.js
├── package-lock.json
├── package.json
├── renovate.json5
├── ruby
├── .asciidoctor
│ └── kroki
│ │ └── .gitkeep
├── .gitignore
├── .rubocop.yml
├── .ruby-version
├── Gemfile
├── Gemfile.lock
├── Rakefile
├── asciidoctor-kroki.gemspec
├── lib
│ ├── asciidoctor-kroki.rb
│ └── asciidoctor
│ │ └── extensions
│ │ ├── asciidoctor_kroki.rb
│ │ └── asciidoctor_kroki
│ │ ├── extension.rb
│ │ └── version.rb
├── spec
│ ├── .rubocop.yml
│ ├── asciidoctor_kroki_block_macro_spec.rb
│ ├── asciidoctor_kroki_client_spec.rb
│ ├── asciidoctor_kroki_diagram_spec.rb
│ ├── asciidoctor_kroki_processor_spec.rb
│ ├── asciidoctor_kroki_spec.rb
│ ├── fixtures
│ │ ├── alice.puml
│ │ ├── config.puml
│ │ └── plantuml-diagram.png
│ ├── require_spec.rb
│ └── rspec_helper.rb
└── tasks
│ ├── bundler.rake
│ ├── lint.rake
│ └── rspec.rake
├── src
├── antora-adapter.js
├── asciidoctor-kroki.js
├── fetch.js
├── http
│ ├── browser-http.js
│ ├── http-client.js
│ └── node-http.js
├── kroki-client.js
├── node-fs.js
└── preprocess.js
├── tasks
├── package.sh
├── publish.js
└── publish.sh
└── test
├── 204-server.js
├── 500-server.js
├── antora
├── .gitignore
├── docs
│ ├── antora.yml
│ └── modules
│ │ └── ROOT
│ │ ├── examples
│ │ ├── ab-all.puml
│ │ ├── ab.puml
│ │ ├── barley.json
│ │ └── styles.puml
│ │ ├── nav.adoc
│ │ ├── pages
│ │ ├── attributes.adoc
│ │ ├── embedding.adoc
│ │ ├── embeddingblockmacro.adoc
│ │ ├── index.adoc
│ │ ├── resolve-antora-resource-ids.adoc
│ │ ├── source-location.adoc
│ │ └── topic
│ │ │ └── index.adoc
│ │ └── partials
│ │ ├── ab-all.adoc
│ │ ├── ab.puml
│ │ └── ab_inc.puml
├── site-remote.yml
├── site.yml
└── test.spec.js
├── block-attributes.spec.js
├── browser
├── index.html
├── run.js
└── test.js
├── fixtures
├── alice.puml
├── cars-repeated-charts.vlite
├── chart.vlite
├── docs
│ ├── data.adoc
│ ├── diagrams
│ │ ├── data
│ │ │ └── seattle-weather.csv
│ │ ├── hello.puml
│ │ ├── style.puml
│ │ └── weather.vlite
│ └── hello.adoc
├── expected
│ ├── alice-bluegray.svg
│ ├── alice.svg
│ ├── cars-repeated-charts.svg
│ └── chart.svg
├── fetch
│ └── doc.adoc
├── macro
│ └── doc.adoc
├── plantuml
│ ├── alice-with-styles.puml
│ ├── diagrams
│ │ ├── hello-with-base-and-note.puml
│ │ ├── hello-with-style.puml
│ │ ├── id.puml
│ │ ├── index.puml
│ │ └── subs.puml
│ ├── hello.puml
│ ├── include
│ │ ├── base.iuml
│ │ ├── grand-parent.iuml
│ │ ├── itself.iuml
│ │ └── parent
│ │ │ ├── child
│ │ │ ├── child.iuml
│ │ │ └── handwritten.iuml
│ │ │ ├── parent.iuml
│ │ │ └── shadow.iuml
│ └── styles
│ │ ├── general with spaces.iuml
│ │ ├── general.iuml
│ │ ├── general.puml
│ │ ├── note.iuml
│ │ ├── sequence.iuml
│ │ ├── style with spaces.iuml
│ │ ├── style-include-once-general.iuml
│ │ └── style.iuml
├── simple.bytefield
└── vegalite-data.csv
├── kroki-client.spec.js
├── node-http.spec.js
├── preprocess.spec.js
├── test.spec.js
└── utils.js
/.asciidoctor/kroki/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/asciidoctor/asciidoctor-kroki/602658c6c1fc0c50b33fd0116961ce6b12afabdc/.asciidoctor/kroki/.gitkeep
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 |
12 | [test/fixtures/**]
13 | insert_final_newline = false
14 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # To match the .editorconfig that asks for lf only
2 | # Otherwise you will end up with files that show up as modified after you IDE
3 | * text=auto eol=lf
4 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: ggrossetie
2 |
--------------------------------------------------------------------------------
/.github/workflows/build-js.yml:
--------------------------------------------------------------------------------
1 | name: Build JavaScript
2 |
3 | on:
4 | push:
5 | paths-ignore:
6 | - 'README.md'
7 | - 'RELEASE.md'
8 | - 'ruby/**'
9 | branches:
10 | - master
11 |
12 | pull_request:
13 | paths-ignore:
14 | - 'README.md'
15 | - 'RELEASE.md'
16 | - 'ruby/**'
17 | branches:
18 | - '*'
19 |
20 | jobs:
21 | build:
22 | strategy:
23 | matrix:
24 | os:
25 | - ubuntu-latest
26 | - windows-latest
27 | node-version:
28 | - 16
29 | - 18
30 | runs-on: ${{ matrix.os }}
31 | steps:
32 | - uses: actions/checkout@v3
33 | - name: Set up Node ${{ matrix.node-version }}
34 | uses: actions/setup-node@v3
35 | with:
36 | node-version: ${{ matrix.node-version }}
37 | # libgbm-dev is required by Puppeteer 3+
38 | - name: Install system dependencies
39 | run: |
40 | sudo apt-get install -y libgbm-dev
41 | if: ${{ runner.os == 'Linux' }}
42 | - name: Install dependencies
43 | run: |
44 | npm ci
45 | - name: Lint and test
46 | run: |
47 | npm run lint
48 | npm t
49 |
--------------------------------------------------------------------------------
/.github/workflows/build-ruby.yml:
--------------------------------------------------------------------------------
1 | name: Build Ruby
2 |
3 | on:
4 | push:
5 | paths:
6 | - 'ruby/**'
7 | branches:
8 | - master
9 | pull_request:
10 | paths:
11 | - 'ruby/**'
12 | branches:
13 | - '*'
14 |
15 | jobs:
16 | build:
17 | strategy:
18 | matrix:
19 | os: [ubuntu-latest, windows-latest]
20 | ruby: ['2.7', '3.2']
21 | runs-on: ${{ matrix.os }}
22 | steps:
23 | - uses: actions/checkout@v3
24 | - uses: ruby/setup-ruby@v1
25 | with:
26 | ruby-version: ${{ matrix.ruby }}
27 | bundler-cache: true
28 | working-directory: ./ruby
29 | - run: bundle exec rake
30 | working-directory: ./ruby
31 | env:
32 | RUBYOPT: "W:deprecated"
33 |
--------------------------------------------------------------------------------
/.github/workflows/release-js.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | on:
4 | push:
5 | tags:
6 | - 'v*' # Push events to matching v*, i.e. v1.0, v2.1.3
7 |
8 | jobs:
9 | build:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v3
13 | - uses: actions/setup-node@v3
14 | with:
15 | node-version: 16
16 | - name: Install dependencies
17 | run: |
18 | npm ci
19 | - name: Lint, build and test
20 | run: |
21 | npm run lint
22 | npm t
23 | publish:
24 | needs: build
25 | runs-on: ubuntu-latest
26 | steps:
27 | - uses: actions/checkout@v3
28 | - uses: actions/setup-node@v3
29 | with:
30 | node-version: 16
31 | # install dependencies
32 | - name: Install dependencies
33 | run: |
34 | npm ci
35 | # package and publish
36 | - name: Package and publish
37 | env:
38 | NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
39 | run: |
40 | ./tasks/package.sh
41 | ./tasks/publish.sh
42 | # create the GitHub release
43 | - name: Create release
44 | id: create_release
45 | uses: actions/create-release@v1.1.4
46 | env:
47 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48 | with:
49 | tag_name: ${{ github.ref }}
50 | release_name: "🐙 JavaScript - ${{ github.ref }}"
51 | draft: false
52 | prerelease: false
53 | # upload assets
54 | - name: Upload source code as a zip file
55 | uses: actions/upload-release-asset@v1.0.2
56 | env:
57 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58 | with:
59 | upload_url: ${{ steps.create_release.outputs.upload_url }}
60 | asset_path: bin/asciidoctor-kroki.dist.zip
61 | asset_name: asciidoctor-kroki.dist.zip
62 | asset_content_type: application/zip
63 | - name: Upload source code as a tar.gz file
64 | uses: actions/upload-release-asset@v1.0.2
65 | env:
66 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67 | with:
68 | upload_url: ${{ steps.create_release.outputs.upload_url }}
69 | asset_path: bin/asciidoctor-kroki.dist.tar.gz
70 | asset_name: asciidoctor-kroki.dist.tar.gz
71 | asset_content_type: application/tar+gzip
72 |
--------------------------------------------------------------------------------
/.github/workflows/release-ruby.yml:
--------------------------------------------------------------------------------
1 | name: Release Ruby
2 |
3 | on:
4 | push:
5 | tags:
6 | - 'ruby-v*' # Push events to matching ruby-v*, i.e. ruby-v1.0, ruby-v2.1.3
7 |
8 | jobs:
9 | build:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v3
13 | - uses: ruby/setup-ruby@v1
14 | with:
15 | ruby-version: 2.7
16 | bundler-cache: true
17 | working-directory: ./ruby
18 | - run: bundle install
19 | working-directory: ./ruby
20 | - run: bundle exec rake
21 | working-directory: ./ruby
22 | publish:
23 | needs: build
24 | runs-on: ubuntu-latest
25 | steps:
26 | - uses: actions/checkout@v3
27 | - uses: ruby/setup-ruby@v1
28 | with:
29 | ruby-version: 2.7
30 | bundler-cache: true
31 | working-directory: ./ruby
32 | - name: Install and test
33 | run: |
34 | bundle install
35 | bundle exec rake
36 | working-directory: ./ruby
37 | - name: Configure credentials
38 | run: |
39 | mkdir -p $HOME/.gem
40 | touch $HOME/.gem/credentials
41 | chmod 0600 $HOME/.gem/credentials
42 | printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}" > $HOME/.gem/credentials
43 | env:
44 | RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
45 | - name: Build gem
46 | run: |
47 | bundle exec rake build
48 | working-directory: ./ruby
49 | - name: Publish to rubygems.org
50 | run: |
51 | gem push pkg/asciidoctor-kroki-${GITHUB_REF#refs/tags/ruby-v}.gem
52 | working-directory: ./ruby
53 | # create the GitHub release
54 | - name: Create release
55 | id: create_release
56 | uses: actions/create-release@v1.1.4
57 | env:
58 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59 | with:
60 | tag_name: ${{ github.ref }}
61 | release_name: "💎 Ruby - ${{ github.ref }}"
62 | draft: false
63 | prerelease: false
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 | .asciidoctor/kroki
3 | .idea/
4 |
--------------------------------------------------------------------------------
/.mocharc.json:
--------------------------------------------------------------------------------
1 | {
2 | "reporter-option": ["maxDiffSize=1048576"]
3 | }
4 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "type": "node",
6 | "request": "launch",
7 | "name": "Mocha All",
8 | "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
9 | "args": [
10 | "--timeout",
11 | "999999",
12 | "--colors",
13 | "${workspaceFolder}/test"
14 | ],
15 | "console": "integratedTerminal",
16 | "internalConsoleOptions": "neverOpen"
17 | },
18 | {
19 | "type": "node",
20 | "request": "launch",
21 | "name": "Mocha Current File",
22 | "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
23 | "args": [
24 | "--timeout",
25 | "999999",
26 | "--colors",
27 | "${file}"
28 | ],
29 | "console": "integratedTerminal",
30 | "internalConsoleOptions": "neverOpen"
31 | }
32 | ]
33 | }
34 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "editor.detectIndentation": false,
3 | "editor.tabSize": 2,
4 | "javascript.format.insertSpaceBeforeFunctionParenthesis": true,
5 | "javascript.format.semicolons": "remove",
6 | "javascript.preferences.quoteStyle": "single",
7 | }
8 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Guillaume Grossetie
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 🖍 Asciidoctor Kroki Extension
2 |
3 | [](https://github.com/ggrossetie/asciidoctor-kroki/actions/workflows/build-js.yml)
4 | [](https://github.com/ggrossetie/asciidoctor-kroki/actions/workflows/build-ruby.yml)
5 | [](https://www.npmjs.com/package/asciidoctor-kroki)
6 | [](https://rubygems.org/gems/asciidoctor-kroki)
7 | [](https://kroki.zulipchat.com/)
8 |
9 | An extension for [Asciidoctor.js](https://github.com/asciidoctor/asciidoctor.js) to convert diagrams to images using [Kroki](https://kroki.io)!
10 |
11 | * [Install](#install)
12 | + [Node.js](#nodejs)
13 | + [Browser](#browser)
14 | + [Ruby](#ruby)
15 | + [Antora Integration](#antora-integration)
16 | * [Usage](#usage)
17 | + [Supported diagram types](#supported-diagram-types)
18 | * [Configuration](#configuration)
19 | * [Using Your Own Kroki](#using-your-own-kroki)
20 | * [Contributing](#contributing)
21 | + [Setup](#setup)
22 | + [Building](#building)
23 |
24 | ## Install
25 |
26 | ### Node.js
27 |
28 | Install the dependencies:
29 |
30 | $ npm i asciidoctor asciidoctor-kroki
31 |
32 | Create a file named `kroki.js` with following content and run it:
33 |
34 | ```javascript
35 | const asciidoctor = require('@asciidoctor/core')()
36 | const kroki = require('asciidoctor-kroki')
37 |
38 | const input = 'plantuml::hello.puml[svg,role=sequence]'
39 |
40 | kroki.register(asciidoctor.Extensions) // <1>
41 | console.log(asciidoctor.convert(input, { safe: 'safe' }))
42 |
43 | const registry = asciidoctor.Extensions.create()
44 | kroki.register(registry) // <2>
45 | console.log(asciidoctor.convert(input, { safe: 'safe', extension_registry: registry }))
46 | ```
47 | **<1>** Register the extension in the global registry
48 | **<2>** Register the extension in a dedicated registry
49 |
50 | ### Browser
51 |
52 | Install the dependencies:
53 |
54 | $ npm i asciidoctor asciidoctor-kroki
55 |
56 | Create a file named `kroki.html` with the following content and open it in your browser:
57 |
58 | ```html
59 |
60 |
Unresolved block macro - plantuml::spec/fixtures/missing.puml[]
27 |Unresolved block macro - plantuml::alice.puml[]
121 |[ERROR: plantuml::spec/fixtures/missing.puml[] - unresolved block macro]
143 |