-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from Mogztter/issue-93-block-attrs
- Loading branch information
Showing
5 changed files
with
173 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* global describe it */ | ||
const chai = require('chai') | ||
const expect = chai.expect | ||
const dirtyChai = require('dirty-chai') | ||
|
||
chai.use(dirtyChai) | ||
|
||
const asciidoctorKroki = require('../src/asciidoctor-kroki.js') | ||
const asciidoctor = require('@asciidoctor/core')() | ||
|
||
describe('Block attributes', () => { | ||
describe('When extension is registered', () => { | ||
it('should convert a diagram with an explicit width and height', () => { | ||
const input = ` | ||
[plantuml,alice-bob,svg,width=100%,height=100%] | ||
.... | ||
alice -> bob | ||
.... | ||
` | ||
const registry = asciidoctor.Extensions.create() | ||
asciidoctorKroki.register(registry) | ||
const html = asciidoctor.convert(input, { extension_registry: registry }) | ||
expect(html).to.equal(`<div class="imageblock kroki"> | ||
<div class="content"> | ||
<img src="https://kroki.io/plantuml/svg/eNpLzMlMTlXQtVNIyk8CABoDA90=" alt="alice-bob" width="100%" height="100%"> | ||
</div> | ||
</div>`) | ||
}) | ||
it('should convert a diagram with a title', () => { | ||
const input = ` | ||
.alice and bob | ||
[plantuml,alice-bob,svg] | ||
.... | ||
alice -> bob | ||
.... | ||
` | ||
const registry = asciidoctor.Extensions.create() | ||
asciidoctorKroki.register(registry) | ||
const html = asciidoctor.convert(input, { extension_registry: registry }) | ||
expect(html).to.equal(`<div class="imageblock kroki"> | ||
<div class="content"> | ||
<img src="https://kroki.io/plantuml/svg/eNpLzMlMTlXQtVNIyk8CABoDA90=" alt="alice and bob"> | ||
</div> | ||
<div class="title">Figure 1. alice and bob</div> | ||
</div>`) | ||
}) | ||
it('should convert a diagram with a caption', () => { | ||
const input = ` | ||
.alice and bob | ||
[plantuml,alice-bob,svg,caption="Figure A. "] | ||
.... | ||
alice -> bob | ||
.... | ||
` | ||
const registry = asciidoctor.Extensions.create() | ||
asciidoctorKroki.register(registry) | ||
const html = asciidoctor.convert(input, { extension_registry: registry }) | ||
expect(html).to.equal(`<div class="imageblock kroki"> | ||
<div class="content"> | ||
<img src="https://kroki.io/plantuml/svg/eNpLzMlMTlXQtVNIyk8CABoDA90=" alt="alice and bob"> | ||
</div> | ||
<div class="title">Figure A. alice and bob</div> | ||
</div>`) | ||
}) | ||
it('should convert a diagram with the float attribute', () => { | ||
const input = ` | ||
[plantuml,alice-bob,svg,float=left] | ||
.... | ||
alice -> bob | ||
.... | ||
` | ||
const registry = asciidoctor.Extensions.create() | ||
asciidoctorKroki.register(registry) | ||
const html = asciidoctor.convert(input, { extension_registry: registry }) | ||
expect(html).to.equal(`<div class="imageblock left kroki"> | ||
<div class="content"> | ||
<img src="https://kroki.io/plantuml/svg/eNpLzMlMTlXQtVNIyk8CABoDA90=" alt="alice-bob"> | ||
</div> | ||
</div>`) | ||
}) | ||
it('should automatically increment caption if diagrams has title and caption is enabled', () => { | ||
const input = ` | ||
.alice and bob | ||
[plantuml,alice-bob,svg] | ||
.... | ||
alice -> bob | ||
.... | ||
.dan and andre | ||
[plantuml,dan-andre,svg] | ||
.... | ||
dan -> andre | ||
.... | ||
` | ||
const registry = asciidoctor.Extensions.create() | ||
asciidoctorKroki.register(registry) | ||
const html = asciidoctor.convert(input, { extension_registry: registry }) | ||
expect(html).to.equal(`<div class="imageblock kroki"> | ||
<div class="content"> | ||
<img src="https://kroki.io/plantuml/svg/eNpLzMlMTlXQtVNIyk8CABoDA90=" alt="alice and bob"> | ||
</div> | ||
<div class="title">Figure 1. alice and bob</div> | ||
</div> | ||
<div class="imageblock kroki"> | ||
<div class="content"> | ||
<img src="https://kroki.io/plantuml/svg/eNpLScxT0LVTSMxLKUoFABg_A-k=" alt="dan and andre"> | ||
</div> | ||
<div class="title">Figure 2. dan and andre</div> | ||
</div>`) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.