asciidoctor-diagram 2.1.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +43 -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 +72 -13
  6. data/docs/modules/ROOT/partials/create_diagram.adoc +45 -42
  7. data/docs/modules/ROOT/partials/uris.adoc +5 -2
  8. data/lib/asciidoctor-diagram/a2s/extension.rb +4 -0
  9. data/lib/asciidoctor-diagram/a2s.rb +1 -0
  10. data/lib/asciidoctor-diagram/barcode/converter.rb +157 -0
  11. data/lib/asciidoctor-diagram/barcode/dependencies.rb +10 -0
  12. data/lib/asciidoctor-diagram/barcode/extension.rb +47 -0
  13. data/lib/asciidoctor-diagram/barcode/svg_outputter.rb +12 -0
  14. data/lib/asciidoctor-diagram/barcode.rb +11 -0
  15. data/lib/asciidoctor-diagram/blockdiag/extension.rb +5 -0
  16. data/lib/asciidoctor-diagram/blockdiag.rb +1 -0
  17. data/lib/asciidoctor-diagram/bpmn/extension.rb +4 -0
  18. data/lib/asciidoctor-diagram/bpmn.rb +1 -0
  19. data/lib/asciidoctor-diagram/bytefield/extension.rb +4 -0
  20. data/lib/asciidoctor-diagram/bytefield.rb +1 -0
  21. data/lib/asciidoctor-diagram/diagram_converter.rb +4 -0
  22. data/lib/asciidoctor-diagram/diagram_processor.rb +62 -6
  23. data/lib/asciidoctor-diagram/diagram_source.rb +23 -7
  24. data/lib/asciidoctor-diagram/diagrams/converter.rb +49 -0
  25. data/lib/asciidoctor-diagram/diagrams/extension.rb +18 -0
  26. data/lib/asciidoctor-diagram/diagrams.rb +8 -0
  27. data/lib/asciidoctor-diagram/ditaa/ditaa-1.3.20.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/http/converter.rb +35 -11
  39. data/lib/asciidoctor-diagram/http/server.rb +1 -1
  40. data/lib/asciidoctor-diagram/lilypond/extension.rb +4 -0
  41. data/lib/asciidoctor-diagram/lilypond.rb +1 -0
  42. data/lib/asciidoctor-diagram/meme/extension.rb +14 -16
  43. data/lib/asciidoctor-diagram/meme.rb +1 -0
  44. data/lib/asciidoctor-diagram/mermaid/extension.rb +4 -0
  45. data/lib/asciidoctor-diagram/mermaid.rb +1 -0
  46. data/lib/asciidoctor-diagram/msc/extension.rb +4 -0
  47. data/lib/asciidoctor-diagram/msc.rb +1 -0
  48. data/lib/asciidoctor-diagram/nomnoml/extension.rb +4 -0
  49. data/lib/asciidoctor-diagram/nomnoml.rb +1 -0
  50. data/lib/asciidoctor-diagram/pikchr/extension.rb +4 -0
  51. data/lib/asciidoctor-diagram/pikchr.rb +1 -0
  52. data/lib/asciidoctor-diagram/plantuml/converter.rb +53 -34
  53. data/lib/asciidoctor-diagram/plantuml/extension.rb +8 -0
  54. data/lib/asciidoctor-diagram/plantuml/plantuml-1.3.20.jar +0 -0
  55. data/lib/asciidoctor-diagram/plantuml.rb +1 -0
  56. data/lib/asciidoctor-diagram/salt.rb +1 -0
  57. data/lib/asciidoctor-diagram/shaape/extension.rb +4 -0
  58. data/lib/asciidoctor-diagram/shaape.rb +1 -0
  59. data/lib/asciidoctor-diagram/smcat/extension.rb +4 -0
  60. data/lib/asciidoctor-diagram/smcat.rb +1 -0
  61. data/lib/asciidoctor-diagram/svgbob/extension.rb +4 -0
  62. data/lib/asciidoctor-diagram/svgbob.rb +1 -0
  63. data/lib/asciidoctor-diagram/symbolator/extension.rb +4 -0
  64. data/lib/asciidoctor-diagram/symbolator.rb +1 -0
  65. data/lib/asciidoctor-diagram/syntrax/converter.rb +1 -1
  66. data/lib/asciidoctor-diagram/syntrax/extension.rb +4 -0
  67. data/lib/asciidoctor-diagram/syntrax.rb +1 -0
  68. data/lib/asciidoctor-diagram/tikz/extension.rb +4 -0
  69. data/lib/asciidoctor-diagram/tikz.rb +1 -0
  70. data/lib/asciidoctor-diagram/umlet/extension.rb +4 -0
  71. data/lib/asciidoctor-diagram/umlet.rb +1 -0
  72. data/lib/asciidoctor-diagram/util/cli_generator.rb +9 -7
  73. data/lib/asciidoctor-diagram/util/server-1.3.20.jar +0 -0
  74. data/lib/asciidoctor-diagram/vega/extension.rb +4 -0
  75. data/lib/asciidoctor-diagram/vega.rb +2 -0
  76. data/lib/asciidoctor-diagram/version.rb +1 -1
  77. data/lib/asciidoctor-diagram/wavedrom/extension.rb +4 -0
  78. data/lib/asciidoctor-diagram/wavedrom.rb +1 -0
  79. data/lib/asciidoctor-diagram.rb +2 -0
  80. data/spec/a2s_spec.rb +9 -5
  81. data/spec/barcode_spec.rb +176 -0
  82. data/spec/blockdiag_spec.rb +7 -3
  83. data/spec/bpmn_spec.rb +7 -3
  84. data/spec/bytefield_spec.rb +9 -5
  85. data/spec/diagrams_spec.rb +27 -0
  86. data/spec/ditaa_spec.rb +7 -3
  87. data/spec/dpic_spec.rb +7 -3
  88. data/spec/erd_spec.rb +7 -3
  89. data/spec/gnuplot_spec.rb +14 -10
  90. data/spec/graphviz_spec.rb +7 -3
  91. data/spec/lilypond_spec.rb +7 -3
  92. data/spec/mermaid_spec.rb +7 -3
  93. data/spec/msc_spec.rb +10 -6
  94. data/spec/nomnoml_spec.rb +9 -5
  95. data/spec/pikchr_spec.rb +7 -3
  96. data/spec/plantuml_spec.rb +114 -3
  97. data/spec/shaape_spec.rb +7 -3
  98. data/spec/shared_examples.rb +161 -0
  99. data/spec/smcat_spec.rb +10 -6
  100. data/spec/svgbob_spec.rb +7 -3
  101. data/spec/symbolator_spec.rb +7 -3
  102. data/spec/syntrax_spec.rb +7 -3
  103. data/spec/test_helper.rb +3 -1
  104. data/spec/tikz_spec.rb +8 -4
  105. data/spec/umlet_spec.rb +6 -3
  106. data/spec/vega_spec.rb +11 -6
  107. data/spec/wavedrom_spec.rb +7 -3
  108. metadata +23 -10
  109. data/lib/asciidoctor-diagram/ditaa/ditaa-1.3.17.jar +0 -0
  110. data/lib/asciidoctor-diagram/plantuml/plantuml-1.3.17.jar +0 -0
  111. data/lib/asciidoctor-diagram/util/server-1.3.17.jar +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5774b8806d487c28498a4701267745c35675ba4bd4963fcd7f4c12bc8bf82e1
4
- data.tar.gz: ac5cd4e68ad0a3baa51493659fab47540cd1f6a465e75048e6d9ac08fd65c3dc
3
+ metadata.gz: f13f5d250305d3a9da90af8da4a0b784c247979b9e23462b8b8bd77f6c92ca0a
4
+ data.tar.gz: 5f757455ea6ba101f8543d87a2bbe06106ed354e09bec89bf3d22959d1674f96
5
5
  SHA512:
6
- metadata.gz: e6fa7123d64dcb5ff61fa681ff05e95fd90d524da0c5bd97f9316ce22407bb188da59a8653c7c7d6af394003e665bd15223e9665163ba6d42d75d633a3f12286
7
- data.tar.gz: 03e75c92be7e6cd34474ef623808a40c7c0c9fb09e5f694517908ea176a9c496bc12f78e111e68015a1744cec4726bd3a4b8dffaf3b2bad5476d709e4ce5842e
6
+ metadata.gz: 2e08ce3f20a0d241e177cbf06680f68149af8adc8e65b6ab25fa57bf1e620aead335d7c8fbe96047bb10b95bf52ce7b22d7c67c3160882e8fd4f0a261c597eb2
7
+ data.tar.gz: 9ff970387205a3686999220bd37e0d54b08f10f5c95be8d37d05764fbf2f46a5606c9efe4184249b951ad845194e108d7d283fd178216fd42958230dbd50afce
data/CHANGELOG.adoc CHANGED
@@ -1,5 +1,48 @@
1
1
  = Asciidoctor-diagram Changelog
2
2
 
3
+ == 2.2.1
4
+
5
+ Bug Fixes::
6
+
7
+ * Issue #366: Improve correctness of SVG images produced by Ditaa
8
+ * Issue #367: Resolve compatibility issue with rqrcode 2.1.0
9
+ * Issue #368: Respect `options` attribute when generating SVG images
10
+
11
+ == 2.2.0
12
+
13
+ Enhancements::
14
+
15
+ * All diagram macros can now be used as inline macros
16
+ * Add support for barcodes
17
+
18
+ Bug Fixes::
19
+
20
+ * Issue #358: Improve error handling when rendering is delegated to an external server (@ahus1)
21
+ * Issue #350: Restore support for document level `syntrax-style` attribute.
22
+
23
+ == 2.1.2
24
+
25
+ Enhancements::
26
+
27
+ * Issue #345: Switch to POST requests when URI length becomes too long
28
+
29
+ Bug Fixes::
30
+
31
+ * Issue #348: Rename Syntrax `style` attribute to `style-file` to avoid clashing with the built-in block style attribute.
32
+
33
+ == 2.1.1
34
+
35
+ Enhancements::
36
+
37
+ * Issue #335: The PlantUML preprocessor is now run locally before delegating rendering to Kroki.
38
+ This avoids file not found errors when using the PlantUML `!include` directive.
39
+ * Issue #339: Add support for a `size-limit` attribute on PlantUML blocks that controls the maximum size of PlantUML diagrams.
40
+ * Issue #341: Add support for https://diagrams.mingrammer.com[Minigrammer Diagrams].
41
+
42
+ Bug Fixes::
43
+
44
+ * Issue #343: The PlantUML preprocessor is now used to resolve `!include` statements instead of using the previous logic provided by this gem.
45
+
3
46
  == 2.1.0
4
47
 
5
48
  Enhancements::
data/docs/antora.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  name: diagram-extension
2
2
  title: Asciidoctor Diagram
3
- version: '2.0'
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.
@@ -16,7 +16,7 @@ or load and register each extension individually.
16
16
  require 'asciidoctor-diagram/<extension_name>'
17
17
  ----
18
18
 
19
- `<extension_name>` can be one of `a2s`, `blockdiag`, `bytefield`, `ditaa`, `dpic`, `erd`, `gnuplot`, `graphviz`, `meme`, `mermaid`, `msc`, `pikchr`, `plantuml`, `shaape`, `smcat`, `svgbob`, `syntrax`, `umlet`, `vega` or `wavedrom`.
19
+ `<extension_name>` can be one of `a2s`, `blockdiag`, `bytefield`, `diagrams`, `ditaa`, `dpic`, `erd`, `gnuplot`, `graphviz`, `meme`, `mermaid`, `msc`, `pikchr`, `plantuml`, `shaape`, `smcat`, `svgbob`, `syntrax`, `umlet`, `vega` or `wavedrom`.
20
20
 
21
21
  Requiring one or more of these files will automatically register the extensions for all processed documents.
22
22
 
@@ -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
 
@@ -73,6 +73,7 @@ The following table lists the tools that are required for each diagram type, the
73
73
  |blockdiag |{uri-blockdiag}[BlockDiag] |`blockdiag`
74
74
  |bpmn |{uri-bpmn}[bpmn-js-cmd] |`bpmn`
75
75
  |bytefield |{uri-bytefield}[bytefield-svg] |`bytefield-svg`
76
+ |diagrams |{uri-python}[Python] |`diagrams-python`
76
77
  |ditaa |{uri-java}[Java] |`java`
77
78
  |dpic |{uri-dpic}[dpic] |`dpic`
78
79
  |erd |{uri-erd}[Erd] |`erd`
@@ -92,7 +93,7 @@ The following table lists the tools that are required for each diagram type, the
92
93
  |smcat |{uri-smcat}[State Machine Cat] |`smcat`
93
94
  |svgbob |{uri-svgbob}[SvgBob] |`svgbob`
94
95
  |symbolator |{uri-symbolator}[Symbolator] |`symbolator`
95
- |syntrax |{uri-syntrax}[Syntrax] |`syntrax`
96
+ |syntrax |{uri-syntrax}[Syntrax]/{uri-jsyntrax}[JSyntrax] |`syntrax`
96
97
  |tikz |A TeX distribution that supports {uri-tikz}[TikZ] |`pdflatex` and `pdf2svg`
97
98
  |umlet |{uri-umlet}[Umlet] |`umlet`
98
99
  |vega |{uri-vega}[vg2png] and/or {uri-vega}[vg2png] |`vg2png` and `vg2svg`
@@ -119,6 +120,35 @@ The target of the block macro tells the extension which image to use as backgrou
119
120
  The first two positional attributes are `top` and `bottom` and are used for the top and bottom label.
120
121
  Occurrences of `//` surrounded by whitespace are interpreted as line breaks.
121
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
+
122
152
  === Diagram Attributes
123
153
 
124
154
  Certain diagram types allow image generation to be customized using attributes.
@@ -140,18 +170,28 @@ This is illustrated for the blockdiag `fontpath` attribute in the example below.
140
170
  <1> Attributes can be specified for all diagram of a certain type at the document level by prefixing them with `<blocktype>-`.
141
171
  In this example, the `fontpath` attribute is specified for all diagrams of type `blockdiag`.
142
172
  <2> The first diagram does not specify an explicit value for `fontpath` so the global `blockdiag-fontpath` value will be used
143
- <3> The second diagram does specifie a `fontpath` value.
173
+ <3> The second diagram does specify a `fontpath` value.
144
174
  This overrides the global `blockdiag-fontpath` value.
145
175
 
146
176
  Each attribute can either be specified at the block level or at the document level.
147
- The attribute name at the block level should be prefixed with the name of the diagram type and a dash.
177
+ The attribute name at the document level should be prefixed with the diagram type name and a dash.
148
178
 
149
179
  ==== Shared Attributes
150
180
 
181
+ The set of shared attributes applies to all diagram types.
182
+ The value for these attributes can be defined at the document level for a single diagram type using the diagram type as prefix or for all diagram types using `diagram` as prefix.
183
+
151
184
  [cols=">,<,<",options="header"]
152
185
  |===
153
- |Name |Default value |Description
154
- |svg-type |unspecified |One of `static`, `inline` or `interactive`. This determines the style of SVG embedding that's used in certain backends. The https://asciidoctor.org/docs/user-manual/#taming-svgs[asciidoctor user guide] describes this in more detail.
186
+ |Name |Default value |Description
187
+ |svg-type |unspecified |One of `static`, `inline` or `interactive`.
188
+ This determines the style of SVG embedding that's used in certain backends.
189
+ The xref:asciidoc:macros:image-svg.adoc[asciidoc spec] describes this in more detail.
190
+ |server-url |unspecified |External service to render diagram.
191
+ Usage removes the need to depend on external tools to be installed locally.
192
+ |server-type |unspecified |One of `plantuml` or `kroki_io`
193
+ |max-get-size |1024 |The maximum size of the URI path for HTTP GET requests.
194
+ If the maximum size is exceeded, POST requests are used instead
155
195
  |===
156
196
 
157
197
  ==== AsciiToSVG
@@ -163,6 +203,20 @@ The attribute name at the block level should be prefixed with the name of the di
163
203
  |noblur |unspecified |Disable drop-shadow blurring
164
204
  |===
165
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
+
166
220
  ==== Blockdiag
167
221
 
168
222
  [cols=">,<,<",options="header"]
@@ -180,6 +234,10 @@ The attribute name at the block level should be prefixed with the name of the di
180
234
  |width |1024 |The target width of the diagram. Does not apply for output type `svg`.
181
235
  |===
182
236
 
237
+ ==== Diagrams
238
+
239
+ No specific attributes.
240
+
183
241
  ==== Ditaa
184
242
 
185
243
  [cols=">,<,<",options="header"]
@@ -261,6 +319,7 @@ The attribute name at the block level should be prefixed with the name of the di
261
319
  |===
262
320
  |Name |Default value |Description
263
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.
264
323
  |===
265
324
 
266
325
  ==== State Machine Cat
@@ -290,7 +349,7 @@ The attribute name at the block level should be prefixed with the name of the di
290
349
  |Name |Default value |Description
291
350
  |heading |unspecifed |Diagram title
292
351
  |scale |1 |A scale factor that is applied to the image.
293
- |style |unspecifed |Path to a style config file to pass to Syntrax.
352
+ |style-file |unspecifed |Path to a style config file to pass to Syntrax.
294
353
  |transparent |false |Makes the background of the image transparent instead of opaque white.
295
354
  |===
296
355
 
@@ -300,4 +359,4 @@ The attribute name at the block level should be prefixed with the name of the di
300
359
  |===
301
360
  |Name |Default value |Description
302
361
  |preamble |unspecified |Code definitions to pass to TikZ.
303
- |===
362
+ |===
@@ -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,37 +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-ditaa}[ditaa] | | |{check}|{check}|
30
- |{uri-dpic}[dpic] | | | |{check}|
31
- |{uri-erd}[erd] | | |{check}|{check}|
32
- |{uri-gnuplot}[gnuplot] |{check}| |{check}|{check}|{check}
33
- |{uri-dot}[graphviz] | |{check}|{check}|{check}|
34
- |<<meme,meme>> |{check}| |{check}| |
35
- |{uri-mermaid}[mermaid] | |{check}|{check}|{check}|
36
- |{uri-mscgen}[msc] | | |{check}|{check}|
37
- |{uri-nomnoml}[nomnoml] | | | |{check}|
38
- |{uri-nwdiag}[nwdiag] | |{check}|{check}|{check}|
39
- |{uri-packetdiag}[packetdiag]| |{check}|{check}|{check}|
40
- |{uri-pikchr}[pikchr] | | | |{check}|
41
- |{uri-plantuml}[plantuml] | | |{check}|{check}|{check}
42
- |{uri-rackdiag}[rackdiag] | |{check}|{check}|{check}|
43
- |{uri-seqdiag}[seqdiag] | |{check}|{check}|{check}|
44
- |{uri-shaape}[shaape] | | |{check}|{check}|
45
- |{uri-smcat}[smcat] | | | |{check}|
46
- |{uri-svgbob}[svgbob] | | | |{check}|
47
- |{uri-symbolator}[symbolator]| |{check}|{check}|{check}|
48
- |{uri-syntrax}[syntrax] | |{check}|{check}|{check}|
49
- |{uri-tikz}[tikz] | |{check}| |{check}|
50
- |{uri-umlet}[umlet] |{check}|{check}|{check}|{check}|
51
- |{uri-vega}[vega] | | |{check}|{check}|
52
- |{uri-vegalite}[vegalite] | | |{check}|{check}|
53
- |{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}|
54
57
  |===
55
58
 
56
59
  :!check:
@@ -81,25 +84,25 @@ The example below illustrates the structure of a basic ditaa block written direc
81
84
  ....
82
85
  ----
83
86
 
84
- The ditaa block above results in the following generated diagram.
87
+ The ditaa block above results in the following diagram.
85
88
 
86
89
  .Rendered ditaa diagram
87
90
  image::asciidoctor-diagram-process.png[Asciidoctor Diagram process diagram,650,319]
88
91
 
89
92
  The rendered ditaa diagram above gets the file name `58372f7d2ceffae9e91fd0a7cbb080b6.png`.
90
93
  That long number is the checksum of the source code calculated by asciidoctor-diagram.
91
- 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.
92
95
 
93
96
  This can be done by either specifying it as the second positional attribute or as a named attribute.
94
97
  Both examples below would result in a file called `ditaa-diagram.png`.
95
98
 
96
99
  ....
97
- [ditaa, "ditaa-diagram"]
100
+ [ditaa, target="ditaa-diagram"]
98
101
  ----
99
102
  <snip>
100
103
  ----
101
104
 
102
- [ditaa, target="ditaa-diagram"]
105
+ [ditaa, "ditaa-diagram"]
103
106
  ----
104
107
  <snip>
105
108
  ----
@@ -111,7 +114,7 @@ The example below illustrates the structure of a basic PlantUML block written di
111
114
  .PlantUML Diagram Syntax
112
115
  [source]
113
116
  ----
114
- [plantuml, diagram-classes, png] // <1> <2> <3>
117
+ [plantuml, target=diagram-classes, format=png] // <1> <2> <3>
115
118
  ....
116
119
  class BlockProcessor
117
120
  class DiagramBlock
@@ -124,8 +127,8 @@ DiagramBlock <|-- PlantUmlBlock
124
127
  ....
125
128
  ----
126
129
  <1> The diagram is written in PlantUML so the first positional attribute is assigned the `plantuml` diagram type.
127
- <2> The name of the generated diagram file (target) is written in the second positional attribute.
128
- <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
129
132
 
130
133
  .Rendered PlantUML diagram
131
134
  image::asciidoctor-diagram-classes.png[Asciidoctor Diagram classes diagram]
@@ -1,10 +1,11 @@
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
5
5
  :uri-blockdiag: http://blockdiag.com
6
6
  :uri-bpmn: https://github.com/gtudan/bpmn-js-cmd
7
7
  :uri-bytefield: https://github.com/Deep-Symmetry/bytefield-svg
8
+ :uri-diagrams: https://diagrams.mingrammer.com
8
9
  :uri-ditaa: http://ditaa.sourceforge.net/
9
10
  :uri-dpic: https://gitlab.com/aplevich/dpic
10
11
  :uri-dot: https://graphviz.gitlab.io/_pages/doc/info/lang.html
@@ -22,6 +23,7 @@
22
23
  :uri-pikchr: https://pikchr.org
23
24
  :uri-plantuml: http://plantuml.sourceforge.net
24
25
  :uri-py-plantuml: https://code.google.com/p/asciidoc-plantuml/
26
+ :uri-python: https://www.python.org
25
27
  :uri-rackdiag: http://blockdiag.com/en/nwdiag/index.html
26
28
  :uri-seqdiag: http://blockdiag.com/en/seqdiag/index.html
27
29
  :uri-shaape: https://github.com/christiangoltz/shaape
@@ -29,10 +31,11 @@
29
31
  :uri-svgbob: https://github.com/ivanceras/svgbobrus
30
32
  :uri-symbolator: https://github.com/kevinpt/symbolator
31
33
  :uri-syntrax: https://kevinpt.github.io/syntrax/
34
+ :uri-jsyntrax: https://atp-mipt.github.io/jsyntrax/
32
35
  :uri-tikz: https://github.com/pgf-tikz/pgf
33
36
  :uri-umlet: http://www.umlet.com/
34
37
  :uri-vega: https://vega.github.io/vega/
35
38
  :uri-vegalite: https://vega.github.io/vega-lite/
36
39
  :uri-wavedrom: http://wavedrom.com
37
40
  :uri-wavedromeditor: https://github.com/wavedrom/wavedrom.github.io/releases
38
- :uri-wavedromcli: https://github.com/wavedrom/cli
41
+ :uri-wavedromcli: https://github.com/wavedrom/cli
@@ -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