asciidoctor-diagram 2.1.2 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +32 -0
  3. data/docs/antora.yml +1 -1
  4. data/docs/modules/ROOT/pages/index.adoc +1 -1
  5. data/docs/modules/ROOT/partials/advanced.adoc +54 -9
  6. data/docs/modules/ROOT/partials/create_diagram.adoc +45 -43
  7. data/docs/modules/ROOT/partials/uris.adoc +3 -2
  8. data/examples/features.adoc +25 -0
  9. data/lib/asciidoctor-diagram/a2s/extension.rb +4 -0
  10. data/lib/asciidoctor-diagram/a2s.rb +1 -0
  11. data/lib/asciidoctor-diagram/barcode/converter.rb +157 -0
  12. data/lib/asciidoctor-diagram/barcode/dependencies.rb +10 -0
  13. data/lib/asciidoctor-diagram/barcode/extension.rb +47 -0
  14. data/lib/asciidoctor-diagram/barcode/svg_outputter.rb +12 -0
  15. data/lib/asciidoctor-diagram/barcode.rb +11 -0
  16. data/lib/asciidoctor-diagram/blockdiag/extension.rb +5 -0
  17. data/lib/asciidoctor-diagram/blockdiag.rb +1 -0
  18. data/lib/asciidoctor-diagram/bpmn/extension.rb +4 -0
  19. data/lib/asciidoctor-diagram/bpmn.rb +1 -0
  20. data/lib/asciidoctor-diagram/bytefield/extension.rb +4 -0
  21. data/lib/asciidoctor-diagram/bytefield.rb +1 -0
  22. data/lib/asciidoctor-diagram/diagram_processor.rb +64 -6
  23. data/lib/asciidoctor-diagram/diagram_source.rb +16 -0
  24. data/lib/asciidoctor-diagram/diagrams/extension.rb +4 -0
  25. data/lib/asciidoctor-diagram/diagrams.rb +1 -0
  26. data/lib/asciidoctor-diagram/ditaa/converter.rb +2 -2
  27. data/lib/asciidoctor-diagram/ditaa/ditaa-1.3.21.jar +0 -0
  28. data/lib/asciidoctor-diagram/ditaa/extension.rb +4 -0
  29. data/lib/asciidoctor-diagram/ditaa.rb +1 -0
  30. data/lib/asciidoctor-diagram/dpic/extension.rb +4 -0
  31. data/lib/asciidoctor-diagram/dpic.rb +1 -0
  32. data/lib/asciidoctor-diagram/erd/extension.rb +4 -0
  33. data/lib/asciidoctor-diagram/erd.rb +1 -0
  34. data/lib/asciidoctor-diagram/gnuplot/extension.rb +4 -0
  35. data/lib/asciidoctor-diagram/gnuplot.rb +1 -0
  36. data/lib/asciidoctor-diagram/graphviz/extension.rb +4 -0
  37. data/lib/asciidoctor-diagram/graphviz.rb +1 -0
  38. data/lib/asciidoctor-diagram/graphviz_py/converter.rb +42 -0
  39. data/lib/asciidoctor-diagram/graphviz_py/extension.rb +18 -0
  40. data/lib/asciidoctor-diagram/graphviz_py.rb +8 -0
  41. data/lib/asciidoctor-diagram/lilypond/extension.rb +4 -0
  42. data/lib/asciidoctor-diagram/lilypond.rb +1 -0
  43. data/lib/asciidoctor-diagram/meme/extension.rb +14 -16
  44. data/lib/asciidoctor-diagram/meme.rb +1 -0
  45. data/lib/asciidoctor-diagram/mermaid/extension.rb +4 -0
  46. data/lib/asciidoctor-diagram/mermaid.rb +1 -0
  47. data/lib/asciidoctor-diagram/msc/extension.rb +4 -0
  48. data/lib/asciidoctor-diagram/msc.rb +1 -0
  49. data/lib/asciidoctor-diagram/nomnoml/extension.rb +4 -0
  50. data/lib/asciidoctor-diagram/nomnoml.rb +1 -0
  51. data/lib/asciidoctor-diagram/pikchr/extension.rb +4 -0
  52. data/lib/asciidoctor-diagram/pikchr.rb +1 -0
  53. data/lib/asciidoctor-diagram/plantuml/converter.rb +25 -16
  54. data/lib/asciidoctor-diagram/plantuml/extension.rb +8 -0
  55. data/lib/asciidoctor-diagram/plantuml/plantuml-1.3.21.jar +0 -0
  56. data/lib/asciidoctor-diagram/plantuml.rb +1 -0
  57. data/lib/asciidoctor-diagram/salt.rb +1 -0
  58. data/lib/asciidoctor-diagram/shaape/extension.rb +4 -0
  59. data/lib/asciidoctor-diagram/shaape.rb +1 -0
  60. data/lib/asciidoctor-diagram/smcat/extension.rb +4 -0
  61. data/lib/asciidoctor-diagram/smcat.rb +1 -0
  62. data/lib/asciidoctor-diagram/svgbob/converter.rb +1 -1
  63. data/lib/asciidoctor-diagram/svgbob/extension.rb +4 -0
  64. data/lib/asciidoctor-diagram/svgbob.rb +1 -0
  65. data/lib/asciidoctor-diagram/symbolator/extension.rb +4 -0
  66. data/lib/asciidoctor-diagram/symbolator.rb +1 -0
  67. data/lib/asciidoctor-diagram/syntrax/converter.rb +1 -1
  68. data/lib/asciidoctor-diagram/syntrax/extension.rb +4 -0
  69. data/lib/asciidoctor-diagram/syntrax.rb +1 -0
  70. data/lib/asciidoctor-diagram/tikz/extension.rb +4 -0
  71. data/lib/asciidoctor-diagram/tikz.rb +1 -0
  72. data/lib/asciidoctor-diagram/umlet/extension.rb +4 -0
  73. data/lib/asciidoctor-diagram/umlet.rb +1 -0
  74. data/lib/asciidoctor-diagram/util/server-1.3.21.jar +0 -0
  75. data/lib/asciidoctor-diagram/vega/extension.rb +4 -0
  76. data/lib/asciidoctor-diagram/vega.rb +2 -0
  77. data/lib/asciidoctor-diagram/version.rb +1 -1
  78. data/lib/asciidoctor-diagram/wavedrom/extension.rb +4 -0
  79. data/lib/asciidoctor-diagram/wavedrom.rb +1 -0
  80. data/lib/asciidoctor-diagram.rb +2 -0
  81. data/spec/a2s_spec.rb +4 -0
  82. data/spec/barcode_spec.rb +176 -0
  83. data/spec/blockdiag_spec.rb +4 -0
  84. data/spec/bpmn_spec.rb +4 -0
  85. data/spec/bytefield_spec.rb +4 -0
  86. data/spec/diagrams_spec.rb +4 -0
  87. data/spec/ditaa_spec.rb +4 -0
  88. data/spec/dpic_spec.rb +4 -0
  89. data/spec/erd_spec.rb +4 -0
  90. data/spec/gnuplot_spec.rb +4 -0
  91. data/spec/graphviz_py_spec.rb +33 -0
  92. data/spec/graphviz_spec.rb +4 -0
  93. data/spec/lilypond_spec.rb +6 -2
  94. data/spec/mermaid_spec.rb +4 -0
  95. data/spec/msc_spec.rb +6 -2
  96. data/spec/nomnoml_spec.rb +4 -0
  97. data/spec/pikchr_spec.rb +4 -0
  98. data/spec/plantuml_spec.rb +67 -1
  99. data/spec/shaape_spec.rb +4 -0
  100. data/spec/shared_examples.rb +161 -0
  101. data/spec/smcat_spec.rb +4 -0
  102. data/spec/svgbob_spec.rb +4 -0
  103. data/spec/symbolator_spec.rb +6 -2
  104. data/spec/syntrax_spec.rb +6 -2
  105. data/spec/test_helper.rb +3 -1
  106. data/spec/tikz_spec.rb +4 -0
  107. data/spec/umlet_spec.rb +3 -0
  108. data/spec/vega_spec.rb +5 -0
  109. data/spec/wavedrom_spec.rb +6 -2
  110. metadata +23 -11
  111. data/lib/asciidoctor-diagram/ditaa/ditaa-1.3.20.jar +0 -0
  112. data/lib/asciidoctor-diagram/plantuml/plantuml-1.3.20.jar +0 -0
  113. data/lib/asciidoctor-diagram/util/server-1.3.20.jar +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c999abc157686ce7101a23d06b8e3cdf83ec0244f1d9697343ec7e9a6afe946
4
- data.tar.gz: 44349c53eefb7e2eb330348a29e2f1a4ee6b60ed1ec5548dc4b3c99ab6fcab5a
3
+ metadata.gz: 629ba788527640ff6cd5bd7c0e6cc18a1a2b7afa4071737b667f95859491dbfc
4
+ data.tar.gz: 762433ab8f23c6d7a4e44fc5d580c77a1fa52b56c47780d1ba28077ae1c309ee
5
5
  SHA512:
6
- metadata.gz: afd079eab9fbfd29a76690012e699c9fa5e45ab14f35b9469defb3a46060e3011b814913af1d5c5365c63157ee8def0101a41ba6b6368d154ad26fe36440ac75
7
- data.tar.gz: e994d6101f63d0fcfde7b04c4763aa43a9eac167cb19295777124cbc25b3042c132869d47597fd33c107b7da583442697bd80852faa9db641d91155cd8b86edd
6
+ metadata.gz: eb2cac4b23d86cc7fb37787208b221a42c839d06b31eff51585a108c674b0517e3c9c72afe1f4ed556e671d4ff5bff06c825cff764098a8925f860975e96146b
7
+ data.tar.gz: 35a265251153d038515a89aea7322373495e6e72d768df42e200c517e905a6b257f8916b7c3b0ff8645a15a8aeff258b345bd7b744c6e514bd6dc7291bf26bdc
data/CHANGELOG.adoc CHANGED
@@ -1,5 +1,37 @@
1
1
  = Asciidoctor-diagram Changelog
2
2
 
3
+ == 2.2.2
4
+
5
+ Enhancements::
6
+
7
+ * Issue #375: Add support for PlantUML include directories (@mskyaxl)
8
+ * Add support for `graphviz-py` (@Alwinator)
9
+ * Issue #380: Allow local PlantUML preprocessing to be disabled using the `preprocess` attribute
10
+
11
+ Bug Fixes::
12
+
13
+ * Issue #370: Only use absolute paths for 'interactive' style SVGs when 'data-uri' is also in use.
14
+
15
+ == 2.2.1
16
+
17
+ Bug Fixes::
18
+
19
+ * Issue #366: Improve correctness of SVG images produced by Ditaa
20
+ * Issue #367: Resolve compatibility issue with rqrcode 2.1.0
21
+ * Issue #368: Respect `options` attribute when generating SVG images
22
+
23
+ == 2.2.0
24
+
25
+ Enhancements::
26
+
27
+ * All diagram macros can now be used as inline macros
28
+ * Add support for barcodes
29
+
30
+ Bug Fixes::
31
+
32
+ * Issue #358: Improve error handling when rendering is delegated to an external server (@ahus1)
33
+ * Issue #350: Restore support for document level `syntrax-style` attribute.
34
+
3
35
  == 2.1.2
4
36
 
5
37
  Enhancements::
data/docs/antora.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  name: diagram-extension
2
2
  title: Asciidoctor Diagram
3
- version: '2.1'
3
+ version: '2.2'
@@ -5,7 +5,7 @@ include::partial$uris.adoc[]
5
5
 
6
6
  Asciidoctor Diagram is a set of Asciidoctor extensions that enable you to add diagrams, which you describe using plain text, to your AsciiDoc document.
7
7
 
8
- The extensions supports the {uri-a2s}[AsciiToSVG], BlockDiag ({uri-blockdiag}[BlockDiag], {uri-seqdiag}[SeqDiag], {uri-actdiag}[ActDiag], {uri-nwdiag}[NwDiag]), {uri-bytefield}[Bytefield-SVG], {uri-ditaa}[Ditaa], {uri-dpic}[dpic], {uri-erd}[Erd], {uri-gnuplot}[Gnuplot], {uri-dot}[GraphViz], {uri-mermaid}[Mermaid], {uri-mscgen}[Msc], {uri-nomnoml}[Nomnoml], {uri-pikchr}[Pikchr], {uri-plantuml}[PlantUML], {uri-shaape}[Shaape], {uri-smcat}[State Machine Cat], {uri-svgbob}[SvgBob], {uri-symbolator}[Symbolator], {uri-syntrax}[Syntrax], {uri-umlet}[UMLet], {uri-vega}[Vega], {uri-vegalite}[Vega-Lite] and {uri-wavedrom}[WaveDrom] syntax.
8
+ The extensions supports the {uri-a2s}[AsciiToSVG], BlockDiag ({uri-blockdiag}[BlockDiag], {uri-seqdiag}[SeqDiag], {uri-actdiag}[ActDiag], {uri-nwdiag}[NwDiag]), {uri-bytefield}[Bytefield-SVG], {uri-ditaa}[Ditaa], {uri-dpic}[dpic], {uri-erd}[Erd], {uri-gnuplot}[Gnuplot], {uri-dot}[GraphViz], {uri-mermaid}[Mermaid], {uri-mscgen}[Msc], {uri-nomnoml}[Nomnoml], {uri-pikchr}[Pikchr], {uri-plantuml}[PlantUML], {uri-shaape}[Shaape], {uri-smcat}[State Machine Cat], {uri-svgbob}[SvgBob], {uri-symbolator}[Symbolator], {uri-syntrax}[Syntrax] / {uri-jsyntrax}[JSyntrax], {uri-umlet}[UMLet], {uri-vega}[Vega], {uri-vegalite}[Vega-Lite] and {uri-wavedrom}[WaveDrom] syntax.
9
9
 
10
10
  Each extension runs the diagram processor to generate an SVG, PNG, or TXT file from the input text.
11
11
  The generated file is then inserted into your converted document.
@@ -26,17 +26,17 @@ You can then manually register the extensions at the appropriate times using the
26
26
 
27
27
  This document explains the various features of asciidoctor-diagram blocks using ditaa diagrams as an example.
28
28
 
29
- === Diagram Block Macro
29
+ === Diagram Macros
30
30
 
31
- The diagram extensions can also be used in in block macro form.
31
+ The diagram extensions can also be used in inline, or block macro form.
32
32
 
33
33
  .Anatomy of a diagram block macro
34
34
  ----
35
- block-name::source-file-name[generated-file-extension] // <1> <2> <3>
35
+ diagram-type::source-file-name[format=output-format] // <1> <2> <3>
36
36
  ----
37
- <1> The macro name is the same as the block name in the block form.
37
+ <1> The macro name specifies the diagram syntax that is being used.
38
38
  <2> The source file name specifies the external file that contains the diagram source code.
39
- <3> The first, optional, positional attribute assigns the file extension (i.e. `format`) to the generated diagram.
39
+ <3> The `format` attribute determines the output image format to use. If a format is not specified, the default output format for the chosen diagram type will be used.
40
40
 
41
41
  When the source file name is a relative path it is resolved with respect to the location of the document being processed.
42
42
 
@@ -93,7 +93,7 @@ The following table lists the tools that are required for each diagram type, the
93
93
  |smcat |{uri-smcat}[State Machine Cat] |`smcat`
94
94
  |svgbob |{uri-svgbob}[SvgBob] |`svgbob`
95
95
  |symbolator |{uri-symbolator}[Symbolator] |`symbolator`
96
- |syntrax |{uri-syntrax}[Syntrax] |`syntrax`
96
+ |syntrax |{uri-syntrax}[Syntrax]/{uri-jsyntrax}[JSyntrax] |`syntrax`
97
97
  |tikz |A TeX distribution that supports {uri-tikz}[TikZ] |`pdflatex` and `pdf2svg`
98
98
  |umlet |{uri-umlet}[Umlet] |`umlet`
99
99
  |vega |{uri-vega}[vg2png] and/or {uri-vega}[vg2png] |`vg2png` and `vg2svg`
@@ -120,6 +120,35 @@ The target of the block macro tells the extension which image to use as backgrou
120
120
  The first two positional attributes are `top` and `bottom` and are used for the top and bottom label.
121
121
  Occurrences of `//` surrounded by whitespace are interpreted as line breaks.
122
122
 
123
+ [[barcode]]
124
+ === The Barcode Extension
125
+
126
+ The barcode extension provides barcode rendering.
127
+ Barcode macros can be specified using blocks, inline macros or block macros using one of the following templates.
128
+
129
+ [source, asciidoc]
130
+ ------
131
+ // Barcode block
132
+ [<type>, <attributes>] <1> <2>
133
+ ----
134
+ <content> <3>
135
+ ----
136
+
137
+ // Barcode block macro
138
+ <type>::<content>[<attributes>]
139
+
140
+ // Barcode inline macro
141
+ <type>::<content>[<attributes>]
142
+ ------
143
+ <1> Type barcode type. One of `bookland`, `codabar`, `code25`, `code25iata`, `code25interleaved`, `code39`, `code93`, `code128`, `code128a`, `code128b`, `code128c`, `ean8`, `ean13`, `gs1_128`, `qrcode`, or `upca`.
144
+ <2> Barcode attributes (see the <<barcode_attributes>> attributes section)
145
+ <3> The content to encode in the barcode
146
+
147
+ By default the `content` field of the barcode macros will be interpreted as the barcode content.
148
+ This works fine for simple barcodes, but for complex data (e.g., a vCard encoded as a QR code) this is not practical.
149
+ If the `external` attribute is set on a barcode macro, the target is interpreted as a file path.
150
+ The barcode content will then be obtained by reading the contents of the referenced file.
151
+
123
152
  === Diagram Attributes
124
153
 
125
154
  Certain diagram types allow image generation to be customized using attributes.
@@ -174,6 +203,20 @@ If the maximum size is exceeded, POST requests are used instead
174
203
  |noblur |unspecified |Disable drop-shadow blurring
175
204
  |===
176
205
 
206
+ [[barcode_attributes]]
207
+ ==== Barcode
208
+
209
+ [cols=">,<,<",options="header"]
210
+ |===
211
+ |Name |Default value |Description
212
+ |height |100 |The height of the bars. (1D only, 2D uses ydim)
213
+ |xdim |1 |The width of the narrowest bar in a barcode. Thicker bars are multiples of the xdim.
214
+ |ydim |Same as xdim |This is the same as xdim, but for the height of the blocks in a 2D barcode.
215
+ |margin |10 |The width of the quiet zone around the barcode.
216
+ |foreground |black |The color of the bars specified as a 3 or 6 digit hex RGB value or HTML color name.
217
+ |background |white |The color of the background specified as a 3 or 6 digit hex RGB value or HTML color name.
218
+ |===
219
+
177
220
  ==== Blockdiag
178
221
 
179
222
  [cols=">,<,<",options="header"]
@@ -274,9 +317,11 @@ No specific attributes.
274
317
 
275
318
  [cols=">,<,<",options="header"]
276
319
  |===
277
- |Name |Default value |Description
278
- |config |unspecified |Path to a config file to pass to PlantUML.
279
- |size-limit |4096 |The maximum dimensions (width and height) of generated diagrams.
320
+ |Name |Default value |Description
321
+ |config |unspecified |Path to a config file to pass to PlantUML.
322
+ |size-limit |4096 |The maximum dimensions (width and height) of generated diagrams.
323
+ |includedir |unspecified |sets a common directory for puml includes (plantuml.include.path)
324
+ |preprocess |true |Preprocess PlantUML code before rendering the diagram.
280
325
  |===
281
326
 
282
327
  ==== State Machine Cat
@@ -4,14 +4,14 @@ A diagram is written inside a literal block, which can accept several attributes
4
4
 
5
5
  .Anatomy of a diagram
6
6
  ----
7
- [diagram-type, generated-file-name, generated-image-format] // <1> <2> <3>
7
+ [diagram-type, target=output-file-name, format=output-format] // <1> <2> <3>
8
8
  .... // <4>
9
9
  Diagram in appropriate syntax
10
10
  ....
11
11
  ----
12
- <1> The first positional attribute in the attribute list specifies the diagram that is being used.
13
- <2> The second, optional positional attribute assigns a file name (i.e. `target`) to the generated diagram. If a target is not specified an auto-generated name will be used.
14
- <3> The third, optional positional attribute specifies the image format to create, specified as a three character file extension.
12
+ <1> The first value in the attribute list specifies the diagram syntax that is being used.
13
+ <2> The `target` attribute specifies the basename of the image file that will be generated. If this attribute is omitted an auto-generated name will be used instead.
14
+ <3> The `format` attribute determines the output image format to use. If a format is not specified, the default output format for the chosen diagram type will be used.
15
15
  <4> Place the attribute list directly on top of the delimited literal block (+....+). You can also use an open block as an alternative (`--`).
16
16
 
17
17
  The following diagram types and output formats are available:
@@ -20,38 +20,40 @@ The following diagram types and output formats are available:
20
20
 
21
21
  [cols=">,5*^",options="header"]
22
22
  |===
23
- |Diagram Type |gif |pdf |png |svg |txt
24
- |{uri-a2s}[a2s] | | | |{check}|
25
- |{uri-actdiag}[actdiag] | |{check}|{check}|{check}|
26
- |{uri-blockdiag}[blockdiag] | |{check}|{check}|{check}|
27
- |{uri-bpmn}[bpmn] | |{check}|{check}|{check}|
28
- |{uri-bytefield}[bytefield] | | | |{check}|
29
- |{uri-diagrams}[diagrams] | |{check}|{check}|{check}|
30
- |{uri-ditaa}[ditaa] | | |{check}|{check}|
31
- |{uri-dpic}[dpic] | | | |{check}|
32
- |{uri-erd}[erd] | | |{check}|{check}|
33
- |{uri-gnuplot}[gnuplot] |{check}| |{check}|{check}|{check}
34
- |{uri-dot}[graphviz] | |{check}|{check}|{check}|
35
- |<<meme,meme>> |{check}| |{check}| |
36
- |{uri-mermaid}[mermaid] | |{check}|{check}|{check}|
37
- |{uri-mscgen}[msc] | | |{check}|{check}|
38
- |{uri-nomnoml}[nomnoml] | | | |{check}|
39
- |{uri-nwdiag}[nwdiag] | |{check}|{check}|{check}|
40
- |{uri-packetdiag}[packetdiag]| |{check}|{check}|{check}|
41
- |{uri-pikchr}[pikchr] | | | |{check}|
42
- |{uri-plantuml}[plantuml] | | |{check}|{check}|{check}
43
- |{uri-rackdiag}[rackdiag] | |{check}|{check}|{check}|
44
- |{uri-seqdiag}[seqdiag] | |{check}|{check}|{check}|
45
- |{uri-shaape}[shaape] | | |{check}|{check}|
46
- |{uri-smcat}[smcat] | | | |{check}|
47
- |{uri-svgbob}[svgbob] | | | |{check}|
48
- |{uri-symbolator}[symbolator]| |{check}|{check}|{check}|
49
- |{uri-syntrax}[syntrax] | |{check}|{check}|{check}|
50
- |{uri-tikz}[tikz] | |{check}| |{check}|
51
- |{uri-umlet}[umlet] |{check}|{check}|{check}|{check}|
52
- |{uri-vega}[vega] | | |{check}|{check}|
53
- |{uri-vegalite}[vegalite] | | |{check}|{check}|
54
- |{uri-wavedrom}[wavedrom] | | |{check}|{check}|
23
+ |Diagram Type |gif |pdf |png |svg |txt
24
+ |{uri-a2s}[a2s] | | | |{check}|
25
+ |{uri-actdiag}[actdiag] | |{check}|{check}|{check}|
26
+ |<<barcode,barcode>> | | |{check}| |{check}
27
+ |{uri-blockdiag}[blockdiag] | |{check}|{check}|{check}|
28
+ |{uri-bpmn}[bpmn] | |{check}|{check}|{check}|
29
+ |{uri-bytefield}[bytefield] | | | |{check}|
30
+ |{uri-diagrams}[diagrams] | |{check}|{check}|{check}|
31
+ |{uri-ditaa}[ditaa] | | |{check}|{check}|
32
+ |{uri-dpic}[dpic] | | | |{check}|
33
+ |{uri-erd}[erd] | | |{check}|{check}|
34
+ |{uri-gnuplot}[gnuplot] |{check}| |{check}|{check}|{check}
35
+ |{uri-dot}[graphviz] | |{check}|{check}|{check}|
36
+ |<<meme,meme>> |{check}| |{check}| |
37
+ |{uri-mermaid}[mermaid] | |{check}|{check}|{check}|
38
+ |{uri-mscgen}[msc] | | |{check}|{check}|
39
+ |{uri-nomnoml}[nomnoml] | | | |{check}|
40
+ |{uri-nwdiag}[nwdiag] | |{check}|{check}|{check}|
41
+ |{uri-packetdiag}[packetdiag] | |{check}|{check}|{check}|
42
+ |{uri-pikchr}[pikchr] | | | |{check}|
43
+ |{uri-plantuml}[plantuml] | | |{check}|{check}|{check}
44
+ |{uri-rackdiag}[rackdiag] | |{check}|{check}|{check}|
45
+ |{uri-seqdiag}[seqdiag] | |{check}|{check}|{check}|
46
+ |{uri-shaape}[shaape] | | |{check}|{check}|
47
+ |{uri-smcat}[smcat] | | | |{check}|
48
+ |{uri-svgbob}[svgbob] | | | |{check}|
49
+ |{uri-symbolator}[symbolator] | |{check}|{check}|{check}|
50
+ |{uri-syntrax}[syntrax] (Syntrax) | |{check}|{check}|{check}|
51
+ |{uri-jsyntrax}[syntrax] (JSyntrax)| | |{check}|{check}|
52
+ |{uri-tikz}[tikz] | |{check}| |{check}|
53
+ |{uri-umlet}[umlet] |{check}|{check}|{check}|{check}|
54
+ |{uri-vega}[vega] | | |{check}|{check}|
55
+ |{uri-vegalite}[vegalite] | | |{check}|{check}|
56
+ |{uri-wavedrom}[wavedrom] | | |{check}|{check}|
55
57
  |===
56
58
 
57
59
  :!check:
@@ -82,25 +84,25 @@ The example below illustrates the structure of a basic ditaa block written direc
82
84
  ....
83
85
  ----
84
86
 
85
- The ditaa block above results in the following generated diagram.
87
+ The ditaa block above results in the following diagram.
86
88
 
87
89
  .Rendered ditaa diagram
88
90
  image::asciidoctor-diagram-process.png[Asciidoctor Diagram process diagram,650,319]
89
91
 
90
92
  The rendered ditaa diagram above gets the file name `58372f7d2ceffae9e91fd0a7cbb080b6.png`.
91
93
  That long number is the checksum of the source code calculated by asciidoctor-diagram.
92
- If you want to give your generated files a more meaningful name, fill in the `target` attribute.
94
+ If you want to give your image files a more meaningful name, fill in the `target` attribute.
93
95
 
94
96
  This can be done by either specifying it as the second positional attribute or as a named attribute.
95
97
  Both examples below would result in a file called `ditaa-diagram.png`.
96
98
 
97
99
  ....
98
- [ditaa, "ditaa-diagram"]
100
+ [ditaa, target="ditaa-diagram"]
99
101
  ----
100
102
  <snip>
101
103
  ----
102
104
 
103
- [ditaa, target="ditaa-diagram"]
105
+ [ditaa, "ditaa-diagram"]
104
106
  ----
105
107
  <snip>
106
108
  ----
@@ -112,7 +114,7 @@ The example below illustrates the structure of a basic PlantUML block written di
112
114
  .PlantUML Diagram Syntax
113
115
  [source]
114
116
  ----
115
- [plantuml, diagram-classes, png] // <1> <2> <3>
117
+ [plantuml, target=diagram-classes, format=png] // <1> <2> <3>
116
118
  ....
117
119
  class BlockProcessor
118
120
  class DiagramBlock
@@ -125,8 +127,8 @@ DiagramBlock <|-- PlantUmlBlock
125
127
  ....
126
128
  ----
127
129
  <1> The diagram is written in PlantUML so the first positional attribute is assigned the `plantuml` diagram type.
128
- <2> The name of the generated diagram file (target) is written in the second positional attribute.
129
- <3> The output format is entered in the third positional attribute.
130
+ <2> The name of the diagram file is given by the `target` attribute.
131
+ <3> The output format is specified using the `format` attribute
130
132
 
131
133
  .Rendered PlantUML diagram
132
134
  image::asciidoctor-diagram-classes.png[Asciidoctor Diagram classes diagram]
@@ -1,4 +1,4 @@
1
- :uri-a2s: https://github.com/dhobsd/asciitosvg
1
+ :uri-a2s: https://github.com/asciitosvg/asciitosvg
2
2
  :uri-actdiag: http://blockdiag.com/en/actdiag/index.html
3
3
  :uri-asciidoctor-api: http://asciidoctor.org/docs/user-manual/#api
4
4
  :uri-asciidoctor-extensions: http://asciidoctor.org/docs/user-manual/#extension-points
@@ -31,10 +31,11 @@
31
31
  :uri-svgbob: https://github.com/ivanceras/svgbobrus
32
32
  :uri-symbolator: https://github.com/kevinpt/symbolator
33
33
  :uri-syntrax: https://kevinpt.github.io/syntrax/
34
+ :uri-jsyntrax: https://atp-mipt.github.io/jsyntrax/
34
35
  :uri-tikz: https://github.com/pgf-tikz/pgf
35
36
  :uri-umlet: http://www.umlet.com/
36
37
  :uri-vega: https://vega.github.io/vega/
37
38
  :uri-vegalite: https://vega.github.io/vega-lite/
38
39
  :uri-wavedrom: http://wavedrom.com
39
40
  :uri-wavedromeditor: https://github.com/wavedrom/wavedrom.github.io/releases
40
- :uri-wavedromcli: https://github.com/wavedrom/cli
41
+ :uri-wavedromcli: https://github.com/wavedrom/cli
@@ -118,6 +118,31 @@ graph ethane {
118
118
  }
119
119
  ----
120
120
 
121
+ With https://github.com/Alwinator/graphviz-py[graphviz_py] you can also use variables and Python code to do calculations:
122
+
123
+ [graphviz_py, "graphviz_py_example", "svg"]
124
+ ----
125
+ graph python_graph {
126
+ {{
127
+ import math
128
+
129
+ value = 0.5
130
+ sin = math.sin(value)
131
+ cos = math.cos(value)
132
+ }}
133
+
134
+ A [label="{{= value }}"];
135
+ B [label="{{= sin }}"];
136
+ C [label="{{= cos }}"];
137
+
138
+ A -- B [headlabel="sin"];
139
+ A -- C [headlabel="cos"];
140
+
141
+ }
142
+ ----
143
+
144
+ Don't forget to install graphviz-py as described https://github.com/Alwinator/graphviz-py#installation[here].
145
+
121
146
  == Using standard asciidoc features
122
147
 
123
148
  Any remaining other attributes that are specified on a diagram block are copied over to the generated block.
@@ -10,5 +10,9 @@ module Asciidoctor
10
10
  class AsciiToSvgBlockMacroProcessor < DiagramBlockMacroProcessor
11
11
  use_converter AsciiToSvgConverter
12
12
  end
13
+
14
+ class AsciiToSvgInlineMacroProcessor < DiagramInlineMacroProcessor
15
+ use_converter AsciiToSvgConverter
16
+ end
13
17
  end
14
18
  end
@@ -4,4 +4,5 @@ require_relative 'a2s/extension'
4
4
  Asciidoctor::Extensions.register do
5
5
  block Asciidoctor::Diagram::AsciiToSvgBlockProcessor, :a2s
6
6
  block_macro Asciidoctor::Diagram::AsciiToSvgBlockMacroProcessor, :a2s
7
+ inline_macro Asciidoctor::Diagram::AsciiToSvgInlineMacroProcessor, :a2s
7
8
  end
@@ -0,0 +1,157 @@
1
+ require_relative '../diagram_converter'
2
+ require_relative 'dependencies'
3
+
4
+ module Asciidoctor
5
+ module Diagram
6
+ # @private
7
+ class BarcodeConverter
8
+ BARCODE_TYPES = [
9
+ :bookland,
10
+ :codabar,
11
+ :code25,
12
+ :code25iata,
13
+ :code25interleaved,
14
+ :code39,
15
+ :code93,
16
+ :code128,
17
+ :code128a,
18
+ :code128b,
19
+ :code128c,
20
+ :ean8,
21
+ :ean13,
22
+ :gs1_128,
23
+ :qrcode,
24
+ :upca,
25
+ ]
26
+
27
+ include DiagramConverter
28
+
29
+ def supported_formats
30
+ [:png, :svg, :txt]
31
+ end
32
+
33
+ def collect_options(source)
34
+ options = {}
35
+
36
+ options[:xdim] = source.attr('xdim')
37
+ options[:ydim] = source.attr('ydim')
38
+ options[:margin] = source.attr('margin')
39
+ options[:height] = source.attr('height')
40
+ options[:foreground] = source.attr('foreground')
41
+ options[:background] = source.attr('background')
42
+
43
+ [:xdim, :ydim, :margin, :height].each { |o| options[o] = options[o].to_i if options[o] }
44
+
45
+ options
46
+ end
47
+
48
+ def convert(source, format, options)
49
+ BarcodeDependencies::BARCODE_DEPENDENCIES.each_pair { |n, v| source.ensure_gem(n, v) }
50
+ require 'barby'
51
+
52
+ code = source.code
53
+ type = source.config[:type]
54
+
55
+ case type
56
+ when :bookland
57
+ require 'barby/barcode/bookland'
58
+ barcode = Barby::Bookland.new(code)
59
+ when :codabar
60
+ require 'barby/barcode/codabar'
61
+ barcode = Barby::Codabar.new(code)
62
+ when :code25
63
+ require 'barby/barcode/code_25'
64
+ barcode = Barby::Code25.new(code)
65
+ when :code25iata
66
+ require 'barby/barcode/code_25_iata'
67
+ barcode = Barby::Code25IATA.new(code)
68
+ when :code25interleaved
69
+ require 'barby/barcode/code_25_interleaved'
70
+ barcode = Barby::Code25Interleaved.new(code)
71
+ when :code39
72
+ require 'barby/barcode/code_39'
73
+ barcode = Barby::Code39.new(code)
74
+ when :code93
75
+ require 'barby/barcode/code_93'
76
+ barcode = Barby::Code93.new(code)
77
+ when :code128
78
+ require 'barby/barcode/code_128'
79
+ barcode = Barby::Code128.new(code)
80
+ when :code128a
81
+ require 'barby/barcode/code_128'
82
+ barcode = Barby::Code128A.new(code)
83
+ when :code128b
84
+ require 'barby/barcode/code_128'
85
+ barcode = Barby::Code128B.new(code)
86
+ when :code128c
87
+ require 'barby/barcode/code_128'
88
+ barcode = Barby::Code128C.new(code)
89
+ when :ean8
90
+ require 'barby/barcode/ean_8'
91
+ barcode = Barby::EAN8.new(code)
92
+ when :ean13
93
+ require 'barby/barcode/ean_13'
94
+ barcode = Barby::EAN13.new(code)
95
+ when :gs1_128
96
+ require 'barby/barcode/code_128'
97
+ code = code.gsub /\([^)]+\)/ do |control|
98
+ case control.upcase
99
+ when '(FNC1)'
100
+ Barby::Code128::FNC1
101
+ when '(FNC2)'
102
+ Barby::Code128::FNC2
103
+ when '(FNC3)'
104
+ Barby::Code128::FNC3
105
+ when '(FNC4)'
106
+ Barby::Code128::FNC4
107
+ when '(CODEA)'
108
+ Barby::Code128::CODEA
109
+ when '(CODEB)'
110
+ Barby::Code128::CODEB
111
+ when '(CODEC)'
112
+ Barby::Code128::CODEC
113
+ when '(SHIFT)'
114
+ Barby::Code128::SHIFT
115
+ when '(SP)'
116
+ ' '
117
+ else
118
+ control
119
+ end
120
+ end
121
+ code = code.gsub(/\s+/, '')
122
+ code = code.prepend(Barby::Code128::FNC1) unless code[0] == Barby::Code128::FNC1
123
+ barcode = Barby::Code128.new(code)
124
+ when :qrcode
125
+ BarcodeDependencies::QRCODE_DEPENDENCIES.each_pair { |n, v| source.ensure_gem(n, v) }
126
+ require 'barby/barcode/qr_code'
127
+ barcode = Barby::QrCode.new(code)
128
+ when :upca
129
+ require 'barby/barcode/ean_13'
130
+ barcode = Barby::UPCA.new(code)
131
+ else
132
+ raise "Unsupported barcode type: #{type}"
133
+ end
134
+
135
+ case format
136
+ when :png
137
+ BarcodeDependencies::PNG_DEPENDENCIES.each_pair { |n, v| source.ensure_gem(n, v) }
138
+ require 'barby/outputter/png_outputter'
139
+ require 'chunky_png/color'
140
+ options[:foreground] = ChunkyPNG::Color(options[:foreground]) if options[:foreground]
141
+ options[:background] = ChunkyPNG::Color(options[:background]) if options[:background]
142
+ barcode.to_png(options)
143
+ when :svg
144
+ require_relative 'svg_outputter'
145
+ options[:foreground] = "##{options[:foreground]}" if options[:foreground] =~ /^[0-9a-f]+$/i
146
+ options[:background] = "##{options[:background]}" if options[:background] =~ /^[0-9a-f]+$/i
147
+ barcode.to_svg(options)
148
+ when :txt
149
+ require 'barby/outputter/ascii_outputter'
150
+ barcode.to_ascii
151
+ else
152
+ raise "Unsupported format: #{format}"
153
+ end
154
+ end
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,10 @@
1
+ module Asciidoctor
2
+ module Diagram
3
+ module BarcodeDependencies
4
+ BARCODE_DEPENDENCIES = {'barby' => '~> 0.6.8'}
5
+ PNG_DEPENDENCIES = {'chunky_png' => '~> 1.4'}
6
+ QRCODE_DEPENDENCIES = {'rqrcode' => '~> 2.0'}
7
+ ALL_DEPENDENCIES = {}.merge(BARCODE_DEPENDENCIES).merge(PNG_DEPENDENCIES).merge(QRCODE_DEPENDENCIES)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,47 @@
1
+ require_relative 'converter'
2
+ require_relative '../diagram_processor'
3
+
4
+ module Asciidoctor
5
+ module Diagram
6
+ module BarcodeProcessor
7
+ def self.check_config(config = {})
8
+ type = config[:type]
9
+ raise "Barcode type not specified in config" if type.nil?
10
+ raise "Unsupported barcode type: '#{type}'" unless BarcodeConverter::BARCODE_TYPES.include?(type)
11
+ end
12
+
13
+ def initialize(name = nil, config = {})
14
+ super
15
+ BarcodeProcessor.check_config(config)
16
+ end
17
+ end
18
+
19
+ module BarcodeMacroProcessor
20
+ def create_source(parent, target, attributes)
21
+ if attributes['external']
22
+ super
23
+ else
24
+ code = parent.sub_attributes(target, :attribute_missing => 'warn')
25
+ ::Asciidoctor::Diagram::ReaderSource.new(self, parent, code, attributes)
26
+ end
27
+ end
28
+ end
29
+
30
+ class BarcodeBlockProcessor < DiagramBlockProcessor
31
+ use_converter BarcodeConverter
32
+ include BarcodeProcessor
33
+ end
34
+
35
+ class BarcodeBlockMacroProcessor < DiagramBlockMacroProcessor
36
+ use_converter BarcodeConverter
37
+ include BarcodeProcessor
38
+ include BarcodeMacroProcessor
39
+ end
40
+
41
+ class BarcodeInlineMacroProcessor < DiagramInlineMacroProcessor
42
+ use_converter BarcodeConverter
43
+ include BarcodeProcessor
44
+ include BarcodeMacroProcessor
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,12 @@
1
+ require 'barby/outputter/svg_outputter'
2
+
3
+ module Barby
4
+ class SvgOutputter
5
+ # Monkey patch to fix foreground color in SVG output
6
+ def bars_to_path(opts={})
7
+ with_options opts do
8
+ %Q|<path stroke="#{foreground}" stroke-width="#{xdim}" d="#{bars_to_path_data(opts)}" />|
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'barcode/extension'
3
+ require_relative 'barcode/converter'
4
+
5
+ Asciidoctor::Extensions.register do
6
+ Asciidoctor::Diagram::BarcodeConverter::BARCODE_TYPES.each do |type|
7
+ block Asciidoctor::Diagram::BarcodeBlockProcessor, type, :type => type
8
+ block_macro Asciidoctor::Diagram::BarcodeBlockMacroProcessor, type, :type => type
9
+ inline_macro Asciidoctor::Diagram::BarcodeInlineMacroProcessor, type, :type => type
10
+ end
11
+ end
@@ -13,6 +13,11 @@ module Asciidoctor
13
13
  use_converter ::Asciidoctor::Diagram.const_get("#{tool}Converter")
14
14
  end
15
15
  ::Asciidoctor::Diagram.const_set("#{tool}BlockMacroProcessor", block_macro)
16
+
17
+ inline_macro = Class.new(DiagramInlineMacroProcessor) do
18
+ use_converter ::Asciidoctor::Diagram.const_get("#{tool}Converter")
19
+ end
20
+ ::Asciidoctor::Diagram.const_set("#{tool}InlineMacroProcessor", inline_macro)
16
21
  end
17
22
  end
18
23
  end
@@ -5,5 +5,6 @@ Asciidoctor::Extensions.register do
5
5
  ['BlockDiag', 'SeqDiag', 'ActDiag', 'NwDiag', 'RackDiag', 'PacketDiag'].each do |tool|
6
6
  block ::Asciidoctor::Diagram.const_get("#{tool}BlockProcessor"), tool.downcase.to_sym
7
7
  block_macro ::Asciidoctor::Diagram.const_get("#{tool}BlockMacroProcessor"), tool.downcase.to_sym
8
+ inline_macro ::Asciidoctor::Diagram.const_get("#{tool}InlineMacroProcessor"), tool.downcase.to_sym
8
9
  end
9
10
  end