Skip to content

Commit

Permalink
resolves #245 adding support for pikchr
Browse files Browse the repository at this point in the history
  • Loading branch information
juracy committed May 26, 2021
1 parent db0d99b commit d6b081a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ Kroki currently supports the following diagram libraries:
* [Nomnoml](https://github.com/skanaar/nomnoml): `nomnoml`
* [NwDiag](https://github.com/blockdiag/nwdiag): `nwdiag`
* [PacketDiag](https://github.com/blockdiag/nwdiag): `packetdiag`
* [Pikchr](https://github.com/drhsqlite/pikchr): `pikchr`
* [PlantUML](https://github.com/plantuml/plantuml): `plantuml`
* [RackDiag](https://github.com/blockdiag/nwdiag): `rackdiag`
* [SeqDiag](https://github.com/blockdiag/seqdiag): `seqdiag`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ module Kroki
nomnoml
nwdiag
packetdiag
pikchr
plantuml
rackdiag
seqdiag
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 @@ -146,7 +146,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')
expect(diagram_names).to include('vegalite', 'plantuml', 'bytefield', 'bpmn', 'excalidraw', 'wavedrom', 'pikchr')
end
it 'should register the extension for the list of supported diagrams' do
doc = Asciidoctor::Document.new
Expand Down
1 change: 1 addition & 0 deletions src/asciidoctor-kroki.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ module.exports.register = function register (registry, context = {}) {
'nomnoml',
'nwdiag',
'packetdiag',
'pikchr',
'plantuml',
'rackdiag',
'seqdiag',
Expand Down
50 changes: 50 additions & 0 deletions test/test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('Registration', () => {
expect(registry['$registered_for_block_macro?']('rackdiag')).to.be.an('object')
expect(registry['$registered_for_block_macro?']('wavedrom')).to.be.an('object')
expect(registry['$registered_for_block_macro?']('excalidraw')).to.be.an('object')
expect(registry['$registered_for_block_macro?']('pikchr')).to.be.an('object')
})
})

Expand Down Expand Up @@ -917,6 +918,55 @@ rackdiag {
expect(html).to.contain('https://kroki.io/bytefield/svg/eNrTSClKLNdNzs8pzc3TzUhNTEktKtbk0gCLJuVXKCg5pqQUpRYXKylUWxUXJOYpmNSiSAdnVqXC5YxQ5AwwhdMTCxSUAhIrc_ITU5QQaktK8nM1AW7MLSU')
expect(html).to.contain('<div class="imageblock kroki">')
})
it('should convert a Pikchr diagram to an image', () => {
const input = `
[pikchr]
....
$r = 0.2in
linerad = 0.75*$r
linewid = 0.25
# Start and end blocks
#
box "element" bold fit
line down 50% from last box.sw
dot rad 250% color black
X0: last.e + (0.3,0)
arrow from last dot to X0
move right 3.9in
box wid 5% ht 25% fill black
X9: last.w - (0.3,0)
arrow from X9 to last box.w
# The main rule that goes straight through from start to finish
#
box "object-definition" italic fit at 11/16 way between X0 and X9
arrow to X9
arrow from X0 to last box.w
# The LABEL: rule
#
arrow right $r from X0 then down 1.25*$r then right $r
oval " LABEL " fit
arrow 50%
oval "\\":\\"" fit
arrow 200%
box "position" italic fit
arrow
line right until even with X9 - ($r,0) \
then up until even with X9 then to X9
arrow from last oval.e right $r*0.5 then up $r*0.8 right $r*0.8
line up $r*0.45 right $r*0.45 then right
....
`
const registry = asciidoctor.Extensions.create()
asciidoctorKroki.register(registry)
const html = asciidoctor.convert(input, { extension_registry: registry })
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 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 d6b081a

Please sign in to comment.