asciidoctor-diagram 1.5.19 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.adoc +71 -0
  3. data/README.adoc +66 -20
  4. data/examples/features.adoc +2 -2
  5. data/lib/asciidoctor-diagram.rb +5 -0
  6. data/lib/asciidoctor-diagram/a2s/converter.rb +59 -0
  7. data/lib/asciidoctor-diagram/a2s/extension.rb +6 -52
  8. data/lib/asciidoctor-diagram/blockdiag/converter.rb +37 -0
  9. data/lib/asciidoctor-diagram/blockdiag/extension.rb +9 -116
  10. data/lib/asciidoctor-diagram/bpmn.rb +7 -0
  11. data/lib/asciidoctor-diagram/bpmn/converter.rb +62 -0
  12. data/lib/asciidoctor-diagram/bpmn/extension.rb +14 -0
  13. data/lib/asciidoctor-diagram/bytefield.rb +7 -0
  14. data/lib/asciidoctor-diagram/bytefield/converter.rb +26 -0
  15. data/lib/asciidoctor-diagram/bytefield/extension.rb +14 -0
  16. data/lib/asciidoctor-diagram/diagram_converter.rb +23 -0
  17. data/lib/asciidoctor-diagram/diagram_processor.rb +374 -0
  18. data/lib/asciidoctor-diagram/diagram_source.rb +322 -0
  19. data/lib/asciidoctor-diagram/ditaa/converter.rb +90 -0
  20. data/lib/asciidoctor-diagram/ditaa/extension.rb +6 -71
  21. data/lib/asciidoctor-diagram/dpic.rb +7 -0
  22. data/lib/asciidoctor-diagram/dpic/converter.rb +30 -0
  23. data/lib/asciidoctor-diagram/dpic/extension.rb +14 -0
  24. data/lib/asciidoctor-diagram/erd/converter.rb +31 -0
  25. data/lib/asciidoctor-diagram/erd/extension.rb +6 -35
  26. data/lib/asciidoctor-diagram/gnuplot/converter.rb +63 -0
  27. data/lib/asciidoctor-diagram/gnuplot/extension.rb +6 -62
  28. data/lib/asciidoctor-diagram/graphviz/converter.rb +32 -0
  29. data/lib/asciidoctor-diagram/graphviz/extension.rb +6 -35
  30. data/lib/asciidoctor-diagram/http/converter.rb +99 -0
  31. data/lib/asciidoctor-diagram/http/server.rb +132 -0
  32. data/lib/asciidoctor-diagram/lilypond/converter.rb +54 -0
  33. data/lib/asciidoctor-diagram/lilypond/extension.rb +6 -53
  34. data/lib/asciidoctor-diagram/meme/converter.rb +122 -0
  35. data/lib/asciidoctor-diagram/meme/extension.rb +5 -107
  36. data/lib/asciidoctor-diagram/mermaid/converter.rb +192 -0
  37. data/lib/asciidoctor-diagram/mermaid/extension.rb +6 -159
  38. data/lib/asciidoctor-diagram/msc/converter.rb +35 -0
  39. data/lib/asciidoctor-diagram/msc/extension.rb +6 -36
  40. data/lib/asciidoctor-diagram/nomnoml/converter.rb +25 -0
  41. data/lib/asciidoctor-diagram/nomnoml/extension.rb +6 -28
  42. data/lib/asciidoctor-diagram/pikchr.rb +7 -0
  43. data/lib/asciidoctor-diagram/pikchr/converter.rb +26 -0
  44. data/lib/asciidoctor-diagram/pikchr/extension.rb +14 -0
  45. data/lib/asciidoctor-diagram/plantuml/converter.rb +117 -0
  46. data/lib/asciidoctor-diagram/plantuml/extension.rb +10 -119
  47. data/lib/asciidoctor-diagram/shaape/converter.rb +25 -0
  48. data/lib/asciidoctor-diagram/shaape/extension.rb +6 -28
  49. data/lib/asciidoctor-diagram/smcat/converter.rb +44 -0
  50. data/lib/asciidoctor-diagram/smcat/extension.rb +6 -42
  51. data/lib/asciidoctor-diagram/svgbob/converter.rb +49 -0
  52. data/lib/asciidoctor-diagram/svgbob/extension.rb +6 -28
  53. data/lib/asciidoctor-diagram/symbolator.rb +7 -0
  54. data/lib/asciidoctor-diagram/symbolator/converter.rb +23 -0
  55. data/lib/asciidoctor-diagram/symbolator/extension.rb +14 -0
  56. data/lib/asciidoctor-diagram/syntrax/converter.rb +58 -0
  57. data/lib/asciidoctor-diagram/syntrax/extension.rb +6 -51
  58. data/lib/asciidoctor-diagram/tikz/converter.rb +75 -0
  59. data/lib/asciidoctor-diagram/tikz/extension.rb +6 -60
  60. data/lib/asciidoctor-diagram/umlet/converter.rb +33 -0
  61. data/lib/asciidoctor-diagram/umlet/extension.rb +6 -28
  62. data/lib/asciidoctor-diagram/util/cli.rb +14 -3
  63. data/lib/asciidoctor-diagram/util/cli_generator.rb +19 -1
  64. data/lib/asciidoctor-diagram/util/gif.rb +2 -2
  65. data/lib/asciidoctor-diagram/util/java.rb +114 -1
  66. data/lib/asciidoctor-diagram/util/java_socket.rb +8 -120
  67. data/lib/asciidoctor-diagram/util/pdf.rb +2 -2
  68. data/lib/asciidoctor-diagram/util/png.rb +2 -2
  69. data/lib/asciidoctor-diagram/util/svg.rb +46 -19
  70. data/lib/asciidoctor-diagram/util/which.rb +0 -29
  71. data/lib/asciidoctor-diagram/vega/converter.rb +47 -0
  72. data/lib/asciidoctor-diagram/vega/extension.rb +6 -44
  73. data/lib/asciidoctor-diagram/version.rb +1 -1
  74. data/lib/asciidoctor-diagram/wavedrom/converter.rb +50 -0
  75. data/lib/asciidoctor-diagram/wavedrom/extension.rb +6 -54
  76. data/lib/ditaa-1.3.15.jar +0 -0
  77. data/lib/plantuml-1.3.15.jar +0 -0
  78. data/lib/plantuml.jar +0 -0
  79. data/lib/server-1.3.15.jar +0 -0
  80. data/spec/a2s_spec.rb +2 -140
  81. data/spec/blockdiag_spec.rb +2 -200
  82. data/spec/bpmn_spec.rb +56 -0
  83. data/spec/bytefield_spec.rb +92 -0
  84. data/spec/ditaa_spec.rb +37 -143
  85. data/spec/dpic_spec.rb +19 -0
  86. data/spec/erd_spec.rb +2 -199
  87. data/spec/gnuplot_spec.rb +2 -255
  88. data/spec/graphviz_spec.rb +6 -145
  89. data/spec/lilypond_spec.rb +2 -140
  90. data/spec/mermaid_spec.rb +62 -209
  91. data/spec/msc_spec.rb +2 -199
  92. data/spec/nomnoml_spec.rb +4 -142
  93. data/spec/pikchr_spec.rb +51 -0
  94. data/spec/plantuml_spec.rb +24 -507
  95. data/spec/shaape_spec.rb +9 -221
  96. data/spec/shared_examples.rb +603 -0
  97. data/spec/smcat_spec.rb +2 -140
  98. data/spec/svgbob_spec.rb +2 -140
  99. data/spec/symbolator_spec.rb +23 -0
  100. data/spec/syntrax_spec.rb +5 -215
  101. data/spec/test_helper.rb +1 -21
  102. data/spec/tikz_spec.rb +65 -15
  103. data/spec/umlet_spec.rb +2 -58
  104. data/spec/vega_spec.rb +4 -117
  105. data/spec/wavedrom_spec.rb +2 -199
  106. metadata +58 -8
  107. data/lib/asciidoctor-diagram/extensions.rb +0 -568
  108. data/lib/ditaa-1.3.13.jar +0 -0
  109. data/lib/plantuml-1.3.13.jar +0 -0
  110. data/lib/server-1.3.13.jar +0 -0
@@ -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
+ 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, 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, code, [:png, :svg]
159
20
  end
@@ -5,147 +5,9 @@ code = <<-eos
5
5
  eos
6
6
 
7
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
8
+ include_examples "block_macro", :lilypond, code, [:png]
36
9
  end
37
10
 
38
11
  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
12
+ include_examples "block", :lilypond, code, [:png]
151
13
  end
@@ -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, 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
@@ -301,4 +100,58 @@ mermaid::mermaid.txt["dark", format="svg", theme="dark"]
301
100
  expect(File.exist?('dark.svg')).to be true
302
101
  expect(File.read('default.svg')).to_not be File.read('dark.svg')
303
102
  end
304
- end
103
+
104
+ it "should respect the puppeteerConfig attribute" do
105
+ seq_diag = <<-eos
106
+ sequenceDiagram
107
+ Alice->>John: Hello John, how are you?
108
+ John-->>Alice: Great!
109
+ eos
110
+
111
+ pptr_config = <<-eos
112
+ {
113
+ "args": ["--no-sandbox"]
114
+ }
115
+ eos
116
+ File.write('pptrconfig.txt', pptr_config)
117
+
118
+ File.write('mermaid.txt', seq_diag)
119
+
120
+ doc = <<-eos
121
+ = Hello, Mermaid!
122
+ Doc Writer <doc@example.com>
123
+
124
+ == First Section
125
+
126
+ mermaid::mermaid.txt[target="with_config", puppeteerConfig="pptrconfig.txt"]
127
+ mermaid::mermaid.txt[target="without_config"]
128
+ eos
129
+
130
+ load_asciidoc doc
131
+ expect(File.exist?('with_config.png')).to be true
132
+ expect(File.exist?('without_config.png')).to be true
133
+ expect(File.size('with_config.png')).to be File.size('without_config.png')
134
+ end
135
+ end
136
+
137
+ describe Asciidoctor::Diagram::MermaidBlockProcessor do
138
+ include_examples "block", :mermaid, code, [:png, :svg]
139
+
140
+ it "should report unsupported scaling factors" do
141
+ doc = <<-eos
142
+ = Hello, Mermaid!
143
+ Doc Writer <doc@example.com>
144
+
145
+ == First Section
146
+
147
+ [mermaid, scale=1.5]
148
+ ----
149
+ sequenceDiagram
150
+ Alice->>John: Hello John, how are you?
151
+ John-->>Alice: Great!
152
+ ----
153
+ eos
154
+
155
+ expect { load_asciidoc doc }.to raise_error(/support.*scale/i)
156
+ end
157
+ end