asciidoctor-diagram 2.0.2 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +78 -1
  3. data/README.adoc +25 -507
  4. data/Rakefile +1 -1
  5. data/docs/antora.yml +3 -0
  6. data/{images → docs/modules/ROOT/images}/asciidoctor-diagram-classes.png +0 -0
  7. data/docs/modules/ROOT/images/asciidoctor-diagram-process.png +0 -0
  8. data/docs/modules/ROOT/pages/index.adoc +21 -0
  9. data/docs/modules/ROOT/partials/advanced.adoc +319 -0
  10. data/docs/modules/ROOT/partials/create_diagram.adoc +132 -0
  11. data/docs/modules/ROOT/partials/generate.adoc +15 -0
  12. data/docs/modules/ROOT/partials/installation.adoc +19 -0
  13. data/docs/modules/ROOT/partials/uris.adoc +40 -0
  14. data/examples/features.adoc +1 -1
  15. data/lib/asciidoctor-diagram.rb +4 -0
  16. data/lib/asciidoctor-diagram/a2s/converter.rb +10 -6
  17. data/lib/asciidoctor-diagram/blockdiag/converter.rb +1 -1
  18. data/lib/asciidoctor-diagram/bpmn/converter.rb +3 -3
  19. data/lib/asciidoctor-diagram/diagram_converter.rb +9 -1
  20. data/lib/asciidoctor-diagram/diagram_processor.rb +92 -48
  21. data/lib/asciidoctor-diagram/diagram_source.rb +71 -24
  22. data/lib/asciidoctor-diagram/diagrams.rb +7 -0
  23. data/lib/asciidoctor-diagram/diagrams/converter.rb +49 -0
  24. data/lib/asciidoctor-diagram/diagrams/extension.rb +14 -0
  25. data/lib/asciidoctor-diagram/ditaa/converter.rb +20 -7
  26. data/lib/asciidoctor-diagram/ditaa/ditaa-1.3.20.jar +0 -0
  27. data/lib/asciidoctor-diagram/dpic.rb +7 -0
  28. data/lib/asciidoctor-diagram/dpic/converter.rb +30 -0
  29. data/lib/asciidoctor-diagram/dpic/extension.rb +14 -0
  30. data/lib/asciidoctor-diagram/gnuplot/converter.rb +8 -8
  31. data/lib/asciidoctor-diagram/graphviz/converter.rb +2 -2
  32. data/lib/asciidoctor-diagram/http/converter.rb +52 -14
  33. data/lib/asciidoctor-diagram/http/server.rb +11 -6
  34. data/lib/asciidoctor-diagram/lilypond/converter.rb +13 -3
  35. data/lib/asciidoctor-diagram/meme/converter.rb +22 -16
  36. data/lib/asciidoctor-diagram/mermaid/converter.rb +45 -14
  37. data/lib/asciidoctor-diagram/msc/converter.rb +2 -2
  38. data/lib/asciidoctor-diagram/pikchr.rb +7 -0
  39. data/lib/asciidoctor-diagram/pikchr/converter.rb +33 -0
  40. data/lib/asciidoctor-diagram/pikchr/extension.rb +14 -0
  41. data/lib/asciidoctor-diagram/plantuml/converter.rb +68 -43
  42. data/lib/asciidoctor-diagram/plantuml/plantuml-1.3.20.jar +0 -0
  43. data/lib/asciidoctor-diagram/smcat/converter.rb +3 -3
  44. data/lib/asciidoctor-diagram/svgbob/converter.rb +6 -2
  45. data/lib/asciidoctor-diagram/symbolator.rb +7 -0
  46. data/lib/asciidoctor-diagram/symbolator/converter.rb +23 -0
  47. data/lib/asciidoctor-diagram/symbolator/extension.rb +14 -0
  48. data/lib/asciidoctor-diagram/syntrax/converter.rb +9 -6
  49. data/lib/asciidoctor-diagram/tikz/converter.rb +20 -1
  50. data/lib/asciidoctor-diagram/umlet/converter.rb +11 -2
  51. data/lib/asciidoctor-diagram/util/cli.rb +16 -1
  52. data/lib/asciidoctor-diagram/util/cli_generator.rb +30 -8
  53. data/lib/asciidoctor-diagram/util/gif.rb +2 -2
  54. data/lib/asciidoctor-diagram/util/java.rb +118 -3
  55. data/lib/asciidoctor-diagram/util/java_jruby.rb +4 -1
  56. data/lib/asciidoctor-diagram/util/java_socket.rb +8 -109
  57. data/lib/asciidoctor-diagram/util/pdf.rb +2 -2
  58. data/lib/asciidoctor-diagram/util/png.rb +2 -2
  59. data/lib/{server-1.3.15.jar → asciidoctor-diagram/util/server-1.3.20.jar} +0 -0
  60. data/lib/asciidoctor-diagram/util/svg.rb +66 -18
  61. data/lib/asciidoctor-diagram/vega/converter.rb +2 -2
  62. data/lib/asciidoctor-diagram/version.rb +1 -1
  63. data/spec/a2s_spec.rb +6 -144
  64. data/spec/blockdiag_spec.rb +6 -204
  65. data/spec/bpmn_spec.rb +52 -92
  66. data/spec/bytefield_spec.rb +6 -144
  67. data/spec/diagrams_spec.rb +23 -0
  68. data/spec/ditaa_spec.rb +6 -144
  69. data/spec/dpic_spec.rb +19 -0
  70. data/spec/erd_spec.rb +6 -203
  71. data/spec/gnuplot_spec.rb +10 -263
  72. data/spec/graphviz_spec.rb +6 -145
  73. data/spec/lilypond_spec.rb +6 -144
  74. data/spec/mermaid_spec.rb +69 -211
  75. data/spec/msc_spec.rb +6 -203
  76. data/spec/nomnoml_spec.rb +7 -145
  77. data/spec/pikchr_spec.rb +69 -0
  78. data/spec/plantuml_spec.rb +63 -553
  79. data/spec/shaape_spec.rb +12 -224
  80. data/spec/shared_examples.rb +603 -0
  81. data/spec/smcat_spec.rb +6 -144
  82. data/spec/svgbob_spec.rb +6 -144
  83. data/spec/symbolator_spec.rb +23 -0
  84. data/spec/syntrax_spec.rb +7 -217
  85. data/spec/test_helper.rb +4 -29
  86. data/spec/tikz_spec.rb +68 -18
  87. data/spec/umlet_spec.rb +3 -59
  88. data/spec/vega_spec.rb +6 -119
  89. data/spec/wavedrom_spec.rb +3 -200
  90. metadata +82 -18
  91. data/README_zh-CN.adoc +0 -336
  92. data/images/asciidoctor-diagram-process.png +0 -0
  93. data/lib/batik-all-1.10.jar +0 -0
  94. data/lib/ditaa-1.3.15.jar +0 -0
  95. data/lib/ditaamini-0.12.jar +0 -0
  96. data/lib/jlatexmath-minimal-1.0.5.jar +0 -0
  97. data/lib/plantuml-1.3.15.jar +0 -0
  98. data/lib/plantuml.jar +0 -0
  99. data/spec/bpmn-example.xml +0 -44
@@ -1,159 +1,20 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe Asciidoctor::Diagram::GraphvizBlockMacroProcessor do
4
- it "should generate PNG images when format is set to 'png'" do
5
- code = <<-eos
3
+ DOT_CODE = <<-eos
6
4
  digraph foo {
7
5
  node [style=rounded]
8
6
  node1 [shape=box]
9
7
  node2 [fillcolor=yellow, style="rounded,filled", shape=diamond]
10
- node3 [shape=record, label="{ a | b | c }"]
8
+ node3 [shape=record, label=" a b c"]
11
9
 
12
10
  node1 -> node2 -> node3
13
11
  }
14
- eos
15
-
16
- File.write('graphviz.txt', code)
17
-
18
- doc = <<-eos
19
- = Hello, graphviz!
20
- Doc Writer <doc@example.com>
21
-
22
- == First Section
23
-
24
- graphviz::graphviz.txt[format="png"]
25
- eos
26
-
27
- d = load_asciidoc doc
28
- expect(d).to_not be_nil
29
-
30
- b = d.find { |bl| bl.context == :image }
31
- expect(b).to_not be_nil
12
+ eos
32
13
 
33
- expect(b.content_model).to eq :empty
34
-
35
- target = b.attributes['target']
36
- expect(target).to_not be_nil
37
- expect(target).to match(/\.png$/)
38
- expect(File.exist?(target)).to be true
39
-
40
- expect(b.attributes['width']).to_not be_nil
41
- expect(b.attributes['height']).to_not be_nil
42
- end
14
+ describe Asciidoctor::Diagram::GraphvizBlockMacroProcessor do
15
+ include_examples "block_macro", :graphviz, DOT_CODE, [:png, :svg]
43
16
  end
44
17
 
45
18
  describe Asciidoctor::Diagram::GraphvizBlockProcessor do
46
- it "should generate PNG images when format is set to 'png'" do
47
- doc = <<-eos
48
- = Hello, graphviz!
49
- Doc Writer <doc@example.com>
50
-
51
- == First Section
52
-
53
- [graphviz, format="png"]
54
- ----
55
- digraph foo {
56
- node [style=rounded]
57
- node1 [shape=box]
58
- node2 [fillcolor=yellow, style="rounded,filled", shape=diamond]
59
- node3 [shape=record, label="{ a | b | c }"]
60
-
61
- node1 -> node2 -> node3
62
- }
63
- ----
64
- eos
65
-
66
- d = load_asciidoc doc
67
- expect(d).to_not be_nil
68
-
69
- b = d.find { |bl| bl.context == :image }
70
- expect(b).to_not be_nil
71
-
72
- expect(b.content_model).to eq :empty
73
-
74
- target = b.attributes['target']
75
- expect(target).to_not be_nil
76
- expect(target).to match(/\.png$/)
77
- expect(File.exist?(target)).to be true
78
-
79
- expect(b.attributes['width']).to_not be_nil
80
- expect(b.attributes['height']).to_not be_nil
81
- end
82
-
83
- it "should generate SVG images when format is set to 'svg'" do
84
- doc = <<-eos
85
- = Hello, graphviz!
86
- Doc Writer <doc@example.com>
87
-
88
- == First Section
89
-
90
- [graphviz, format="svg"]
91
- ----
92
- digraph foo {
93
- node [style=rounded]
94
- node1 [shape=box]
95
- node2 [fillcolor=yellow, style="rounded,filled", shape=diamond]
96
- node3 [shape=record, label="{ a | b | c }"]
97
-
98
- node1 -> node2 -> node3
99
- }
100
- ----
101
- eos
102
-
103
- d = load_asciidoc doc
104
- expect(d).to_not be_nil
105
-
106
- b = d.find { |bl| bl.context == :image }
107
- expect(b).to_not be_nil
108
-
109
- expect(b.content_model).to eq :empty
110
-
111
- target = b.attributes['target']
112
- expect(target).to_not be_nil
113
- expect(target).to match(/\.svg$/)
114
- expect(File.exist?(target)).to be true
115
-
116
- expect(b.attributes['width']).to_not be_nil
117
- expect(b.attributes['height']).to_not be_nil
118
- end
119
-
120
- it "should raise an error when when format is set to an invalid value" do
121
- doc = <<-eos
122
- = Hello, graphviz!
123
- Doc Writer <doc@example.com>
124
-
125
- == First Section
126
-
127
- [graphviz, format="foobar"]
128
- ----
129
- ----
130
- eos
131
-
132
- expect { load_asciidoc doc }.to raise_error(/support.*format/i)
133
- end
134
-
135
- it "should support neato layout engine" do
136
- doc = <<-eos
137
- = Hello, graphviz!
138
- Doc Writer <doc@example.com>
139
-
140
- == First Section
141
-
142
- [graphviz, layout=neato]
143
- ----
144
- digraph g { rankdir=LR; Text->Graphviz->Image }
145
- ----
146
- eos
147
-
148
- d = load_asciidoc doc
149
- expect(d).to_not be_nil
150
-
151
- b = d.find { |bl| bl.context == :image }
152
- expect(b).to_not be_nil
153
-
154
- expect(b.content_model).to eq :empty
155
-
156
- target = b.attributes['target']
157
- expect(File.exist?(target)).to be true
158
- end
19
+ include_examples "block", :graphviz, DOT_CODE, [:png, :svg]
159
20
  end
@@ -1,151 +1,13 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- code = <<-eos
3
+ LILYPOND_CODE = <<-eos
4
4
  \\relative c' { f d f a d f e d cis a cis e a g f e }
5
5
  eos
6
6
 
7
- describe Asciidoctor::Diagram::LilypondBlockMacroProcessor, :broken_on_windows do
8
- it "should generate PNG images when format is set to 'png'" do
9
- File.write('lilypond.txt', code)
10
-
11
- doc = <<-eos
12
- = Hello, Lilypond!
13
- Doc Writer <doc@example.com>
14
-
15
- == First Section
16
-
17
- lilypond::lilypond.txt[format="png"]
18
- eos
19
-
20
- d = load_asciidoc doc
21
- expect(d).to_not be_nil
22
-
23
- b = d.find { |bl| bl.context == :image }
24
- expect(b).to_not be_nil
25
-
26
- expect(b.content_model).to eq :empty
27
-
28
- target = b.attributes['target']
29
- expect(target).to_not be_nil
30
- expect(target).to match(/\.png/)
31
- expect(File.exist?(target)).to be true
32
-
33
- expect(b.attributes['width']).to_not be_nil
34
- expect(b.attributes['height']).to_not be_nil
35
- end
7
+ describe Asciidoctor::Diagram::LilypondBlockMacroProcessor do
8
+ include_examples "block_macro", :lilypond, LILYPOND_CODE, [:png]
36
9
  end
37
10
 
38
- describe Asciidoctor::Diagram::LilypondBlockProcessor, :broken_on_windows do
39
- it "should generate PNG images when format is set to 'png'" do
40
- doc = <<-eos
41
- = Hello, Lilypond!
42
- Doc Writer <doc@example.com>
43
-
44
- == First Section
45
-
46
- [lilypond, format="png"]
47
- ----
48
- #{code}
49
- ----
50
- eos
51
-
52
- d = load_asciidoc doc
53
- expect(d).to_not be_nil
54
-
55
- b = d.find { |bl| bl.context == :image }
56
- expect(b).to_not be_nil
57
-
58
- expect(b.content_model).to eq :empty
59
-
60
- target = b.attributes['target']
61
- expect(target).to_not be_nil
62
- expect(target).to match(/\.png/)
63
- expect(File.exist?(target)).to be true
64
-
65
- expect(b.attributes['width']).to_not be_nil
66
- expect(b.attributes['height']).to_not be_nil
67
- end
68
-
69
- it "should raise an error when when format is set to an invalid value" do
70
- doc = <<-eos
71
- = Hello, Lilypond!
72
- Doc Writer <doc@example.com>
73
-
74
- == First Section
75
-
76
- [lilypond, format="foobar"]
77
- ----
78
- ----
79
- eos
80
-
81
- expect { load_asciidoc doc }.to raise_error(/support.*format/i)
82
- end
83
-
84
- it "should not regenerate images when source has not changed" do
85
- File.write('lilypond.txt', code)
86
-
87
- doc = <<-eos
88
- = Hello, Lilypond!
89
- Doc Writer <doc@example.com>
90
-
91
- == First Section
92
-
93
- lilypond::lilypond.txt
94
-
95
- [lilypond, format="png"]
96
- ----
97
- #{code}
98
- ----
99
- eos
100
-
101
- d = load_asciidoc doc
102
- b = d.find { |bl| bl.context == :image }
103
- expect(b).to_not be_nil
104
- target = b.attributes['target']
105
- mtime1 = File.mtime(target)
106
-
107
- sleep 1
108
-
109
- d = load_asciidoc doc
110
-
111
- mtime2 = File.mtime(target)
112
-
113
- expect(mtime2).to eq mtime1
114
- end
115
-
116
- it "should handle two block macros with the same source" do
117
- File.write('lilypond.txt', code)
118
-
119
- doc = <<-eos
120
- = Hello, Lilypond!
121
- Doc Writer <doc@example.com>
122
-
123
- == First Section
124
-
125
- lilypond::lilypond.txt[]
126
- lilypond::lilypond.txt[]
127
- eos
128
-
129
- load_asciidoc doc
130
- expect(File.exist?('lilypond.png')).to be true
131
- end
132
-
133
- it "should respect target attribute in block macros" do
134
- File.write('lilypond.txt', code)
135
-
136
- doc = <<-eos
137
- = Hello, Lilypond!
138
- Doc Writer <doc@example.com>
139
-
140
- == First Section
141
-
142
- lilypond::lilypond.txt["foobar"]
143
- lilypond::lilypond.txt["foobaz"]
144
- eos
145
-
146
- load_asciidoc doc
147
- expect(File.exist?('foobar.png')).to be true
148
- expect(File.exist?('foobaz.png')).to be true
149
- expect(File.exist?('lilypond.png')).to be false
150
- end
151
- end
11
+ describe Asciidoctor::Diagram::LilypondBlockProcessor do
12
+ include_examples "block", :lilypond, LILYPOND_CODE, [:png]
13
+ end
data/spec/mermaid_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- code = <<-eos
3
+ MERMAID_CODE = <<-eos
4
4
  graph LR
5
5
  A[Square Rect] -- Link text --> B((Circle))
6
6
  A --> C(Round Rect)
@@ -9,208 +9,7 @@ graph LR
9
9
  eos
10
10
 
11
11
  describe Asciidoctor::Diagram::MermaidBlockMacroProcessor do
12
- it "should generate PNG images when format is set to 'png'" do
13
- File.write('mermaid.txt', code)
14
-
15
- doc = <<-eos
16
- = Hello, Mermaid!
17
- Doc Writer <doc@example.com>
18
-
19
- == First Section
20
-
21
- mermaid::mermaid.txt[format="png"]
22
- eos
23
-
24
- d = load_asciidoc doc
25
- expect(d).to_not be_nil
26
-
27
- b = d.find { |bl| bl.context == :image }
28
- expect(b).to_not be_nil
29
-
30
- expect(b.content_model).to eq :empty
31
-
32
- target = b.attributes['target']
33
- expect(target).to_not be_nil
34
- expect(target).to match(/\.png$/)
35
- expect(File.exist?(target)).to be true
36
-
37
- expect(b.attributes['width']).to_not be_nil
38
- expect(b.attributes['height']).to_not be_nil
39
- end
40
-
41
- it "should generate SVG images when format is set to 'svg'" do
42
- File.write('mermaid.txt', code)
43
-
44
- doc = <<-eos
45
- = Hello, Mermaid!
46
- Doc Writer <doc@example.com>
47
-
48
- == First Section
49
-
50
- mermaid::mermaid.txt[format="svg"]
51
- eos
52
-
53
- d = load_asciidoc doc
54
- expect(d).to_not be_nil
55
-
56
- b = d.find { |bl| bl.context == :image }
57
- expect(b).to_not be_nil
58
-
59
- expect(b.content_model).to eq :empty
60
-
61
- target = b.attributes['target']
62
- expect(target).to_not be_nil
63
- expect(target).to match(/\.svg/)
64
- expect(File.exist?(target)).to be true
65
-
66
- expect(b.attributes['width']).to_not be_nil
67
- expect(b.attributes['height']).to_not be_nil
68
- end
69
- end
70
-
71
- describe Asciidoctor::Diagram::MermaidBlockProcessor do
72
- it "should generate PNG images when format is set to 'png'" do
73
- doc = <<-eos
74
- = Hello, Mermaid!
75
- Doc Writer <doc@example.com>
76
-
77
- == First Section
78
-
79
- [mermaid, format="png"]
80
- ----
81
- #{code}
82
- ----
83
- eos
84
-
85
- d = load_asciidoc doc
86
- expect(d).to_not be_nil
87
-
88
- b = d.find { |bl| bl.context == :image }
89
- expect(b).to_not be_nil
90
-
91
- expect(b.content_model).to eq :empty
92
-
93
- target = b.attributes['target']
94
- expect(target).to_not be_nil
95
- expect(target).to match(/\.png$/)
96
- expect(File.exist?(target)).to be true
97
-
98
- expect(b.attributes['width']).to_not be_nil
99
- expect(b.attributes['height']).to_not be_nil
100
- end
101
-
102
- it "should generate SVG images when format is set to 'svg'" do
103
- doc = <<-eos
104
- = Hello, Mermaid!
105
- Doc Writer <doc@example.com>
106
-
107
- == First Section
108
-
109
- [mermaid, format="svg"]
110
- ----
111
- #{code}
112
- ----
113
- eos
114
-
115
- d = load_asciidoc doc
116
- expect(d).to_not be_nil
117
-
118
- b = d.find { |bl| bl.context == :image }
119
- expect(b).to_not be_nil
120
-
121
- expect(b.content_model).to eq :empty
122
-
123
- target = b.attributes['target']
124
- expect(target).to_not be_nil
125
- expect(target).to match(/\.svg/)
126
- expect(File.exist?(target)).to be true
127
-
128
- expect(b.attributes['width']).to_not be_nil
129
- expect(b.attributes['height']).to_not be_nil
130
- end
131
-
132
- it "should raise an error when when format is set to an invalid value" do
133
- doc = <<-eos
134
- = Hello, Mermaid!
135
- Doc Writer <doc@example.com>
136
-
137
- == First Section
138
-
139
- [mermaid, format="foobar"]
140
- ----
141
- ----
142
- eos
143
-
144
- expect { load_asciidoc doc }.to raise_error(/support.*format/i)
145
- end
146
-
147
- it "should not regenerate images when source has not changed" do
148
- File.write('mermaid.txt', code)
149
-
150
- doc = <<-eos
151
- = Hello, Mermaid!
152
- Doc Writer <doc@example.com>
153
-
154
- == First Section
155
-
156
- mermaid::mermaid.txt
157
-
158
- [mermaid, format="png"]
159
- ----
160
- #{code}
161
- ----
162
- eos
163
-
164
- d = load_asciidoc doc
165
- b = d.find { |bl| bl.context == :image }
166
- expect(b).to_not be_nil
167
- target = b.attributes['target']
168
- mtime1 = File.mtime(target)
169
-
170
- sleep 1
171
-
172
- d = load_asciidoc doc
173
-
174
- mtime2 = File.mtime(target)
175
-
176
- expect(mtime2).to eq mtime1
177
- end
178
-
179
- it "should handle two block macros with the same source" do
180
- File.write('mermaid.txt', code)
181
-
182
- doc = <<-eos
183
- = Hello, Mermaid!
184
- Doc Writer <doc@example.com>
185
-
186
- == First Section
187
-
188
- mermaid::mermaid.txt[]
189
- mermaid::mermaid.txt[]
190
- eos
191
-
192
- load_asciidoc doc
193
- expect(File.exist?('mermaid.png')).to be true
194
- end
195
-
196
- it "should respect target attribute in block macros" do
197
- File.write('mermaid.txt', code)
198
-
199
- doc = <<-eos
200
- = Hello, Mermaid!
201
- Doc Writer <doc@example.com>
202
-
203
- == First Section
204
-
205
- mermaid::mermaid.txt["foobar"]
206
- mermaid::mermaid.txt["foobaz"]
207
- eos
208
-
209
- load_asciidoc doc
210
- expect(File.exist?('foobar.png')).to be true
211
- expect(File.exist?('foobaz.png')).to be true
212
- expect(File.exist?('mermaid.png')).to be false
213
- end
12
+ include_examples "block_macro", :mermaid, MERMAID_CODE, [:png, :svg]
214
13
 
215
14
  it "should respect the sequenceConfig attribute" do
216
15
  seq_diag = <<-eos
@@ -240,8 +39,8 @@ Doc Writer <doc@example.com>
240
39
 
241
40
  == First Section
242
41
 
243
- mermaid::mermaid.txt["with_config", sequenceConfig="seqconfig.txt"]
244
- mermaid::mermaid.txt["without_config"]
42
+ mermaid::mermaid.txt[target="with_config", sequenceConfig="seqconfig.txt"]
43
+ mermaid::mermaid.txt[target="without_config"]
245
44
  eos
246
45
 
247
46
  load_asciidoc doc
@@ -266,8 +65,8 @@ Doc Writer <doc@example.com>
266
65
 
267
66
  == First Section
268
67
 
269
- mermaid::mermaid.txt["with_width", width="700"]
270
- mermaid::mermaid.txt["without_width"]
68
+ mermaid::mermaid.txt[target="with_width", width="700"]
69
+ mermaid::mermaid.txt[target="without_width"]
271
70
  eos
272
71
 
273
72
  load_asciidoc doc
@@ -292,8 +91,8 @@ Doc Writer <doc@example.com>
292
91
 
293
92
  == First Section
294
93
 
295
- mermaid::mermaid.txt["default", format="svg"]
296
- mermaid::mermaid.txt["dark", format="svg", theme="dark"]
94
+ mermaid::mermaid.txt[target="default", format="svg"]
95
+ mermaid::mermaid.txt[target="dark", format="svg", theme="dark"]
297
96
  eos
298
97
 
299
98
  load_asciidoc doc
@@ -324,8 +123,8 @@ Doc Writer <doc@example.com>
324
123
 
325
124
  == First Section
326
125
 
327
- mermaid::mermaid.txt["with_config", puppeteerConfig="pptrconfig.txt"]
328
- mermaid::mermaid.txt["without_config"]
126
+ mermaid::mermaid.txt[target="with_config", puppeteerConfig="pptrconfig.txt"]
127
+ mermaid::mermaid.txt[target="without_config"]
329
128
  eos
330
129
 
331
130
  load_asciidoc doc
@@ -334,3 +133,62 @@ mermaid::mermaid.txt["without_config"]
334
133
  expect(File.size('with_config.png')).to be File.size('without_config.png')
335
134
  end
336
135
  end
136
+
137
+ describe Asciidoctor::Diagram::MermaidBlockProcessor do
138
+ include_examples "block", :mermaid, MERMAID_CODE, [:png, :svg]
139
+
140
+ it "should work with kroki.io" do
141
+ doc = <<-eos
142
+ = Hello, kroki!
143
+ :diagram-server-url: https://kroki.io/
144
+ :diagram-server-type: kroki_io
145
+ Doc Writer <doc@example.com>
146
+
147
+ == First Section
148
+
149
+ [mermaid, format=svg]
150
+ ----
151
+ graph TD
152
+ A[ Anyone ] -->|Can help | B( Go to github.com/yuzutech/kroki )
153
+ B --> C{ How to contribute? }
154
+ C --> D[ Reporting bugs ]
155
+ C --> E[ Sharing ideas ]
156
+ C --> F[ Advocating ]
157
+ ----
158
+ eos
159
+
160
+ d = load_asciidoc doc
161
+ expect(d).to_not be_nil
162
+
163
+ b = d.find { |bl| bl.context == :image }
164
+ expect(b).to_not be_nil
165
+
166
+ expect(b.content_model).to eq :empty
167
+
168
+ target = b.attributes['target']
169
+ expect(target).to_not be_nil
170
+ expect(target).to match(/\.svg$/)
171
+ expect(File.exist?(target)).to be true
172
+
173
+ expect(b.attributes['width']).to_not be_nil
174
+ expect(b.attributes['height']).to_not be_nil
175
+ end
176
+
177
+ it "should report unsupported scaling factors" do
178
+ doc = <<-eos
179
+ = Hello, Mermaid!
180
+ Doc Writer <doc@example.com>
181
+
182
+ == First Section
183
+
184
+ [mermaid, scale=1.5]
185
+ ----
186
+ sequenceDiagram
187
+ Alice->>John: Hello John, how are you?
188
+ John-->>Alice: Great!
189
+ ----
190
+ eos
191
+
192
+ expect { load_asciidoc doc }.to raise_error(/support.*scale/i)
193
+ end
194
+ end