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,77 +1,14 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe Asciidoctor::Diagram::PlantUmlBlockMacroProcessor do
4
- it "should generate PNG images when format is set to 'png'" do
5
- code = <<-eos
3
+ PLANTUML_CODE = <<-eos
6
4
  User -> (Start)
7
5
  User --> (Use the application) : Label
8
6
 
9
7
  :Main Admin: ---> (Use the application) : Another label
10
- eos
11
-
12
- File.write('plantuml.txt', code)
13
-
14
- doc = <<-eos
15
- = Hello, PlantUML!
16
- Doc Writer <doc@example.com>
17
-
18
- == First Section
19
-
20
- plantuml::plantuml.txt[format="png"]
21
- eos
22
-
23
- d = load_asciidoc doc
24
- expect(d).to_not be_nil
8
+ eos
25
9
 
26
- b = d.find { |bl| bl.context == :image }
27
- expect(b).to_not be_nil
28
-
29
- expect(b.content_model).to eq :empty
30
-
31
- target = b.attributes['target']
32
- expect(target).to_not be_nil
33
- expect(target).to match(/\.png$/)
34
- expect(File.exist?(target)).to be true
35
-
36
- expect(b.attributes['width']).to_not be_nil
37
- expect(b.attributes['height']).to_not be_nil
38
- end
39
-
40
- it "should generate PNG images when format is set to 'png'" do
41
- code = <<-eos
42
- User -> (Start)
43
- User --> (Use the application) : Label
44
-
45
- :Main Admin: ---> (Use the application) : Another label
46
- eos
47
-
48
- File.write('plantuml.txt', code)
49
-
50
- doc = <<-eos
51
- = Hello, PlantUML!
52
- Doc Writer <doc@example.com>
53
-
54
- == First Section
55
-
56
- plantuml::plantuml.txt[format="png"]
57
- eos
58
-
59
- d = load_asciidoc doc
60
- expect(d).to_not be_nil
61
-
62
- b = d.find { |bl| bl.context == :image }
63
- expect(b).to_not be_nil
64
-
65
- expect(b.content_model).to eq :empty
66
-
67
- target = b.attributes['target']
68
- expect(target).to_not be_nil
69
- expect(target).to match(/\.png$/)
70
- expect(File.exist?(target)).to be true
71
-
72
- expect(b.attributes['width']).to_not be_nil
73
- expect(b.attributes['height']).to_not be_nil
74
- end
10
+ describe Asciidoctor::Diagram::PlantUmlBlockMacroProcessor do
11
+ include_examples "block_macro", :plantuml, PLANTUML_CODE, [:png, :svg, :txt]
75
12
 
76
13
  it 'should support substitutions in diagram code' do
77
14
  code = <<-eos
@@ -216,153 +153,23 @@ plantuml::dir/plantuml.txt[format="svg", subs=attributes+]
216
153
  content = File.read(target, :encoding => Encoding::UTF_8)
217
154
  expect(content).to_not include('!include')
218
155
  end
219
-
220
- it 'should generate blocks with figure captions' do
221
- code = <<-eos
222
- User -> (Start)
223
- User --> (Use the application) : Label
224
-
225
- :Main Admin: ---> (Use the application) : Another label
226
- eos
227
-
228
- File.write('plantuml.txt', code)
229
-
230
- doc = <<-eos
231
- = Hello, PlantUML!
232
- Doc Writer <doc@example.com>
233
-
234
- == First Section
235
-
236
- .This is a UML diagram
237
- plantuml::plantuml.txt[format="png"]
238
- eos
239
-
240
- d = load_asciidoc doc
241
- expect(d).to_not be_nil
242
-
243
- b = d.find { |bl| bl.context == :image }
244
- expect(b).to_not be_nil
245
-
246
- expect(b.caption).to match(/Figure \d+/)
247
- end
248
156
  end
249
157
 
250
158
  describe Asciidoctor::Diagram::PlantUmlBlockProcessor do
251
- it "should generate PNG images when format is set to 'png'" do
252
- doc = <<-eos
253
- = Hello, PlantUML!
254
- Doc Writer <doc@example.com>
255
-
256
- == First Section
257
-
258
- [plantuml, format="png"]
259
- ----
260
- User -> (Start)
261
- User --> (Use the application) : Label
262
-
263
- :Main Admin: ---> (Use the application) : Another label
264
- ----
265
- eos
266
-
267
- d = load_asciidoc doc
268
- expect(d).to_not be_nil
269
-
270
- b = d.find { |bl| bl.context == :image }
271
- expect(b).to_not be_nil
272
-
273
- expect(b.content_model).to eq :empty
274
-
275
- target = b.attributes['target']
276
- expect(target).to_not be_nil
277
- expect(target).to match(/\.png$/)
278
- expect(File.exist?(target)).to be true
279
-
280
- expect(b.attributes['width']).to_not be_nil
281
- expect(b.attributes['height']).to_not be_nil
282
- end
283
-
284
- it "should generate SVG images when format is set to 'svg'" do
285
- doc = <<-eos
286
- = Hello, PlantUML!
287
- Doc Writer <doc@example.com>
288
-
289
- == First Section
290
-
291
- [plantuml, format="svg"]
292
- ----
293
- User -> (Start)
294
- User --> (Use the application) : Label
295
-
296
- :Main Admin: ---> (Use the application) : Another label
297
- ----
298
- eos
299
-
300
- d = load_asciidoc doc
301
- expect(d).to_not be_nil
302
-
303
- b = d.find { |bl| bl.context == :image }
304
- expect(b).to_not be_nil
159
+ include_examples "block", :plantuml, PLANTUML_CODE, [:png, :svg, :txt]
305
160
 
306
- expect(b.content_model).to eq :empty
307
-
308
- target = b.attributes['target']
309
- expect(target).to_not be_nil
310
- expect(target).to match(/\.svg/)
311
- expect(File.exist?(target)).to be true
312
-
313
- expect(b.attributes['width']).to_not be_nil
314
- expect(b.attributes['height']).to_not be_nil
315
- end
316
-
317
- it "should respect the svg-type attribute when format is set to 'svg'" do
161
+ it "should work with plantuml.com" do
318
162
  doc = <<-eos
319
- = Hello, PlantUML!
163
+ = Hello, kroki!
164
+ :diagram-server-url: http://plantuml.com/plantuml
165
+ :diagram-server-type: plantuml
320
166
  Doc Writer <doc@example.com>
321
167
 
322
168
  == First Section
323
169
 
324
- [plantuml, format="svg", svg-type="inline"]
325
- ----
326
- User -> (Start)
327
- User --> (Use the application) : Label
328
-
329
- :Main Admin: ---> (Use the application) : Another label
170
+ [plantuml, format=svg]
330
171
  ----
331
- eos
332
-
333
- d = load_asciidoc doc
334
- expect(d).to_not be_nil
335
-
336
- b = d.find { |bl| bl.context == :image }
337
- expect(b).to_not be_nil
338
-
339
- expect(b.content_model).to eq :empty
340
-
341
- target = b.attributes['target']
342
- expect(target).to_not be_nil
343
- expect(target).to match(/\.svg/)
344
- expect(File.exist?(target)).to be true
345
-
346
- expect(b.attributes['opts']).to eq('inline')
347
-
348
- expect(b.attributes['width']).to_not be_nil
349
- expect(b.attributes['height']).to_not be_nil
350
- end
351
-
352
- it "should respect the diagram-svg-type attribute when format is set to 'svg'" do
353
- doc = <<-eos
354
- = Hello, PlantUML!
355
- :diagram-svg-type: inline
356
- Doc Writer <doc@example.com>
357
-
358
- == First Section
359
-
360
- [plantuml, format="svg"]
361
- ----
362
- User -> (Start)
363
- User --> (Use the application) : Label
364
-
365
- :Main Admin: ---> (Use the application) : Another label
172
+ #{PLANTUML_CODE}
366
173
  ----
367
174
  eos
368
175
 
@@ -376,57 +183,13 @@ User --> (Use the application) : Label
376
183
 
377
184
  target = b.attributes['target']
378
185
  expect(target).to_not be_nil
379
- expect(target).to match(/\.svg/)
186
+ expect(target).to match(/\.svg$/)
380
187
  expect(File.exist?(target)).to be true
381
188
 
382
- expect(b.attributes['opts']).to eq('inline')
383
-
384
189
  expect(b.attributes['width']).to_not be_nil
385
190
  expect(b.attributes['height']).to_not be_nil
386
191
  end
387
192
 
388
- it "should generate literal blocks when format is set to 'txt'" do
389
- doc = <<-eos
390
- = Hello, PlantUML!
391
- Doc Writer <doc@example.com>
392
-
393
- == First Section
394
-
395
- [plantuml, format="txt"]
396
- ----
397
- User -> (Start)
398
- User --> (Use the application) : Label
399
-
400
- :Main Admin: ---> (Use the application) : Another label
401
- ----
402
- eos
403
-
404
- d = load_asciidoc doc
405
- expect(d).to_not be_nil
406
-
407
- b = d.find { |bl| bl.context == :literal }
408
- expect(b).to_not be_nil
409
-
410
- expect(b.content_model).to eq :verbatim
411
-
412
- expect(b.attributes['target']).to be_nil
413
- end
414
-
415
- it 'should raise an error when when format is set to an invalid value' do
416
- doc = <<-eos
417
- = Hello, PlantUML!
418
- Doc Writer <doc@example.com>
419
-
420
- == First Section
421
-
422
- [plantuml, format="foobar"]
423
- ----
424
- ----
425
- eos
426
-
427
- expect { load_asciidoc doc }.to raise_error(/support.*format/i)
428
- end
429
-
430
193
  it 'should use plantuml configuration when specified as a document attribute' do
431
194
  doc = <<-eos
432
195
  = Hello, PlantUML!
@@ -460,275 +223,7 @@ skinparam ArrowColor #DEADBE
460
223
  expect(File.exist?(target)).to be true
461
224
 
462
225
  svg = File.read(target, :encoding => Encoding::UTF_8)
463
- expect(svg).to match(/<path.*fill="#DEADBE"/)
464
- end
465
-
466
- it 'should not regenerate images when source has not changed' do
467
- code = <<-eos
468
- User -> (Start)
469
- User --> (Use the application) : Label
470
-
471
- :Main Admin: ---> (Use the application) : Another label
472
- eos
473
-
474
- File.write('plantuml.txt', code)
475
-
476
- doc = <<-eos
477
- = Hello, PlantUML!
478
- Doc Writer <doc@example.com>
479
-
480
- == First Section
481
-
482
- plantuml::plantuml.txt
483
-
484
- [plantuml, format="png"]
485
- ----
486
- actor Foo1
487
- boundary Foo2
488
- Foo1 -> Foo2 : To boundary
489
- ----
490
- eos
491
-
492
- d = load_asciidoc doc
493
- b = d.find { |bl| bl.context == :image }
494
- target = b.attributes['target']
495
- mtime1 = File.mtime(target)
496
-
497
- sleep 1
498
-
499
- d = load_asciidoc doc
500
-
501
- mtime2 = File.mtime(target)
502
-
503
- expect(mtime2).to eq mtime1
504
- end
505
-
506
- it 'should handle two block macros with the same source' do
507
- code = <<-eos
508
- User -> (Start)
509
- User --> (Use the application) : Label
510
-
511
- :Main Admin: ---> (Use the application) : Another label
512
- eos
513
-
514
- File.write('plantuml.txt', code)
515
-
516
- doc = <<-eos
517
- = Hello, PlantUML!
518
- Doc Writer <doc@example.com>
519
-
520
- == First Section
521
-
522
- plantuml::plantuml.txt[]
523
- plantuml::plantuml.txt[]
524
- eos
525
-
526
- load_asciidoc doc
527
- expect(File.exist?('plantuml.png')).to be true
528
- end
529
-
530
- it 'should respect target attribute in block macros' do
531
- code = <<-eos
532
- User -> (Start)
533
- User --> (Use the application) : Label
534
-
535
- :Main Admin: ---> (Use the application) : Another label
536
- eos
537
-
538
- File.write('plantuml.txt', code)
539
-
540
- doc = <<-eos
541
- = Hello, PlantUML!
542
- Doc Writer <doc@example.com>
543
-
544
- == First Section
545
-
546
- plantuml::plantuml.txt["foobar"]
547
- plantuml::plantuml.txt["foobaz"]
548
- eos
549
-
550
- load_asciidoc doc
551
- expect(File.exist?('foobar.png')).to be true
552
- expect(File.exist?('foobaz.png')).to be true
553
- expect(File.exist?('plantuml.png')).to be false
554
- end
555
-
556
- it 'should respect target attribute values with relative paths in block macros' do
557
- code = <<-eos
558
- User -> (Start)
559
- User --> (Use the application) : Label
560
-
561
- :Main Admin: ---> (Use the application) : Another label
562
- eos
563
-
564
- File.write('plantuml.txt', code)
565
-
566
- doc = <<-eos
567
- = Hello, PlantUML!
568
- Doc Writer <doc@example.com>
569
-
570
- == First Section
571
-
572
- plantuml::plantuml.txt["test/foobar"]
573
- plantuml::plantuml.txt["test2/foobaz"]
574
- eos
575
-
576
- load_asciidoc doc
577
- expect(File.exist?('test/foobar.png')).to be true
578
- expect(File.exist?('test2/foobaz.png')).to be true
579
- expect(File.exist?('plantuml.png')).to be false
580
- end
581
-
582
- it 'should write files to outdir if set' do
583
- doc = <<-eos
584
- = Hello, PlantUML!
585
- Doc Writer <doc@example.com>
586
-
587
- == First Section
588
-
589
- [plantuml, format="svg"]
590
- ----
591
- actor Foo1
592
- boundary Foo2
593
- Foo1 -> Foo2 : To boundary
594
- ----
595
- eos
596
-
597
- d = load_asciidoc doc, {:attributes => {'outdir' => 'foo'}}
598
- b = d.find { |bl| bl.context == :image }
599
-
600
- target = b.attributes['target']
601
- expect(target).to_not be_nil
602
- expect(File.exist?(target)).to be false
603
- expect(File.exist?(File.expand_path(target, 'foo'))).to be true
604
- end
605
-
606
- it 'should write files to to_dir if set' do
607
- doc = <<-eos
608
- = Hello, PlantUML!
609
- Doc Writer <doc@example.com>
610
-
611
- == First Section
612
-
613
- [plantuml, format="svg"]
614
- ----
615
- actor Foo1
616
- boundary Foo2
617
- Foo1 -> Foo2 : To boundary
618
- ----
619
- eos
620
-
621
- d = load_asciidoc doc, {:to_dir => 'foo'}
622
- b = d.find { |bl| bl.context == :image }
623
-
624
- target = b.attributes['target']
625
- expect(target).to_not be_nil
626
- expect(File.exist?(target)).to be false
627
- expect(File.exist?(File.expand_path(target, 'foo'))).to be true
628
- end
629
-
630
- it 'should write files to to_dir if set when embedded in table' do
631
- doc = <<-eos
632
- = Hello, PlantUML!
633
- Doc Writer <doc@example.com>
634
-
635
- == First Section
636
-
637
- |===
638
- |Type | Example
639
-
640
- |graphviz
641
- a|
642
- [plantuml, format="svg"]
643
- ----
644
- actor Foo1
645
- boundary Foo2
646
- Foo1 -> Foo2 : To boundary
647
- ----
648
- |===
649
- eos
650
-
651
- d = load_asciidoc doc, {:to_dir => 'foo'}
652
- b = d.find { |bl| bl.context == :image }
653
-
654
- target = b.attributes['target']
655
- expect(target).to_not be_nil
656
- expect(File.exist?(target)).to be false
657
- expect(File.exist?(File.expand_path(target, 'foo'))).to be true
658
- end
659
-
660
- it 'should write files to imagesoutdir if set' do
661
- doc = <<-eos
662
- = Hello, PlantUML!
663
- Doc Writer <doc@example.com>
664
-
665
- == First Section
666
-
667
- [plantuml, format="svg"]
668
- ----
669
- actor Foo1
670
- boundary Foo2
671
- Foo1 -> Foo2 : To boundary
672
- ----
673
- eos
674
-
675
- d = load_asciidoc doc, {:attributes => {'imagesoutdir' => 'bar', 'outdir' => 'foo'}}
676
- b = d.find { |bl| bl.context == :image }
677
-
678
- target = b.attributes['target']
679
- expect(target).to_not be_nil
680
- expect(File.exist?(target)).to be false
681
- expect(File.exist?(File.expand_path(target, 'bar'))).to be true
682
- expect(File.exist?(File.expand_path(target, 'foo'))).to be false
683
- end
684
-
685
- it 'should omit width/height attributes when generating docbook' do
686
- doc = <<-eos
687
- = Hello, PlantUML!
688
- Doc Writer <doc@example.com>
689
-
690
- == First Section
691
-
692
- [plantuml, format="png"]
693
- ----
694
- User -> (Start)
695
- ----
696
- eos
697
-
698
- d = load_asciidoc doc, :attributes => {'backend' => 'docbook5'}
699
- expect(d).to_not be_nil
700
-
701
- b = d.find { |bl| bl.context == :image }
702
- expect(b).to_not be_nil
703
-
704
- target = b.attributes['target']
705
- expect(File.exist?(target)).to be true
706
-
707
- expect(b.attributes['width']).to be_nil
708
- expect(b.attributes['height']).to be_nil
709
- end
710
-
711
- it 'should generate blocks with figure captions' do
712
- doc = <<-eos
713
- = Hello, PlantUML!
714
- Doc Writer <doc@example.com>
715
-
716
- == First Section
717
-
718
- .Caption for my UML diagram
719
- [plantuml, format="png"]
720
- ----
721
- User -> (Start)
722
- ----
723
- eos
724
-
725
- d = load_asciidoc doc
726
- expect(d).to_not be_nil
727
-
728
- b = d.find { |bl| bl.context == :image }
729
- expect(b).to_not be_nil
730
-
731
- expect(b.caption).to match(/Figure \d+/)
226
+ expect(svg).to match(/<[^<]+ fill=["']#DEADBE["']/)
732
227
  end
733
228
 
734
229
  it 'should support salt diagrams using salt block type' do
@@ -834,41 +329,6 @@ salt
834
329
  expect(b.attributes['height']).to be_nil
835
330
  end
836
331
 
837
- it 'should support scaling diagrams' do
838
- doc = <<-eos
839
- = Hello, PlantUML!
840
- Doc Writer <doc@example.com>
841
-
842
- == First Section
843
-
844
- [plantuml, format="png"]
845
- ----
846
- A -> B
847
- ----
848
- eos
849
-
850
- scaled_doc = <<-eos
851
- = Hello, PlantUML!
852
- Doc Writer <doc@example.com>
853
-
854
- == First Section
855
-
856
- [plantuml, format="png", scale="1.5"]
857
- ----
858
- A -> B
859
- ----
860
- eos
861
-
862
- d = load_asciidoc doc, :attributes => {'backend' => 'html5'}
863
- unscaled_image = d.find { |bl| bl.context == :image }
864
-
865
- d = load_asciidoc scaled_doc, :attributes => {'backend' => 'html5'}
866
- scaled_image = d.find { |bl| bl.context == :image }
867
-
868
- expect(scaled_image.attributes['width']).to be_within(1).of(unscaled_image.attributes['width'] * 1.5)
869
- expect(scaled_image.attributes['height']).to be_within(1).of(unscaled_image.attributes['height'] * 1.5)
870
- end
871
-
872
332
  it 'should handle embedded creole images correctly' do
873
333
  creole_doc = <<-eos
874
334
  = Hello, PlantUML!
@@ -1163,4 +623,54 @@ Bob; Alice; foo
1163
623
  load_asciidoc doc
1164
624
  }.to raise_error(/syntax error/i)
1165
625
  end
626
+
627
+ it "should support complex preprocessor usage" do
628
+ doc = <<-eos
629
+ = Hello, PlantUML!
630
+ Doc Writer <doc@example.com>
631
+
632
+ == First Section
633
+
634
+ [plantuml,format="png"]
635
+ ----
636
+ @startuml
637
+ !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
638
+
639
+ !define DEVICONS https://raw.githubusercontent.com/tupadr3/plantuml-icon-font-sprites/master/devicons
640
+ !define FONTAWESOME https://raw.githubusercontent.com/tupadr3/plantuml-icon-font-sprites/master/font-awesome-5
641
+ !include DEVICONS/angular.puml
642
+ !include DEVICONS/java.puml
643
+ !include DEVICONS/msql_server.puml
644
+ !include FONTAWESOME/users.puml
645
+
646
+ LAYOUT_WITH_LEGEND()
647
+
648
+ Person(user, "Customer", "People that need products", "users")
649
+ Container(spa, "SPA", "angular", "The main interface that the customer interacts with", "angular")
650
+ Container(api, "API", "java", "Handles all business logic", "java")
651
+ ContainerDb(db, "Database", "Microsoft SQL", "Holds product, order and invoice information", "msql_server")
652
+
653
+ Rel(user, spa, "Uses", "https")
654
+ Rel(spa, api, "Uses", "https")
655
+ Rel_R(api, db, "Reads/Writes")
656
+ @enduml
657
+ ----
658
+ eos
659
+
660
+ d = load_asciidoc doc
661
+ expect(d).to_not be_nil
662
+
663
+ b = d.find { |bl| bl.context == :image }
664
+ expect(b).to_not be_nil
665
+
666
+ expect(b.content_model).to eq :empty
667
+
668
+ target = b.attributes['target']
669
+ expect(target).to_not be_nil
670
+ expect(target).to match(/\.png$/)
671
+ expect(File.exist?(target)).to be true
672
+
673
+ expect(b.attributes['width']).to_not be_nil
674
+ expect(b.attributes['height']).to_not be_nil
675
+ end
1166
676
  end