asciidoctor-diagram 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of asciidoctor-diagram might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09488e585ecab52e38188d04020d60aa17873bea47c3043055f8f59770f9d1aa'
4
- data.tar.gz: ab9eab53cc00fc988ccd4518ac62e91f815ea06cfc3d3615824a24d63efb07a7
3
+ metadata.gz: 3db88f4195c4c1bdb7ef894672db503b597107fff0c42c88d609acc1ce4cc612
4
+ data.tar.gz: c03d251525c9377265af7292b7a5bcad2ca17b3f11e0cc131b5befa50ea3c31b
5
5
  SHA512:
6
- metadata.gz: 7e75194b60961b932b7ca141448948c92404db4557b83611c28786de97fb7b36e30d434189815729a4aab79620dd6a1e90d7eb0281c1a5a3a66356730f319892
7
- data.tar.gz: d7b8c2f8d8678e6299dd309292cc524d704830d6a882ae9228620d466862f0e37c9b1540a57090641f04f3499fcfcbf46f08933febfaa0dbb15579d33c3d1c64
6
+ metadata.gz: 63c88296049bdf6d9e347acfbd1c0587faaf3e6e545b260ea593734d85844eb9c8c19575fb5414a81ae29867e828d72b952807fe2f9bc2e35418cef30664c1d8
7
+ data.tar.gz: 1b1dbac8878b37e601637b5f62cfd15cf8e1ce751d07d81910efa1d9ee87a10316d29ad20916919cad67121ab6557e8b58a26f05206583095419b691c0db7bfb
@@ -1,5 +1,21 @@
1
1
  = Asciidoctor-diagram Changelog
2
2
 
3
+
4
+ == 2.0.3
5
+
6
+ Enhancements::
7
+
8
+ * Issue #261: Ensure generated SVG diagrams always specify a view box
9
+ * Issue #284: Add support for HTTP redirect responses when using a rendering server
10
+ * Issue #290: Add support for Pikchr
11
+ * Add support for dpic
12
+ * Add support for Symboloator (@gsmecher)
13
+
14
+ Bug Fixes::
15
+
16
+ * Issue #247: Fix `svg-type`/`diagram-svg-type`.
17
+ * Issue #257: Avoid potential hangs when generating Mermaid diagrams
18
+
3
19
  == 2.0.2
4
20
 
5
21
  Enhancements::
@@ -21,18 +21,20 @@ ifndef::env-site[:status:]
21
21
  :uri-bpmn: https://github.com/gtudan/bpmn-js-cmd
22
22
  :uri-bytefield: https://github.com/Deep-Symmetry/bytefield-svg
23
23
  :uri-ditaa: http://ditaa.sourceforge.net/
24
+ :uri-dpic: https://gitlab.com/aplevich/dpic
24
25
  :uri-dot: https://graphviz.gitlab.io/_pages/doc/info/lang.html
25
26
  :uri-erd: https://github.com/BurntSushi/erd
26
27
  :uri-gnuplot: http://gnuplot.info
27
28
  :uri-graphviz: https://graphviz.gitlab.io
28
29
  :uri-imagemagick: http://www.imagemagick.org
29
30
  :uri-java: http://java.sun.com
30
- :uri-mermaid: https://github.com/mermaidjs/mermaid.cli
31
+ :uri-mermaid: https://github.com/mermaid-js/mermaid-cli
31
32
  :uri-mscgen: http://www.mcternan.me.uk/mscgen/
32
33
  :uri-nomnoml: http://nomnoml.com
33
34
  :uri-nwdiag: http://blockdiag.com/en/nwdiag/index.html
34
35
  :uri-packetdiag: http://blockdiag.com/en/nwdiag/index.html
35
36
  :uri-phantomjs: http://phantomjs.org
37
+ :uri-pikchr: https://pikchr.org
36
38
  :uri-plantuml: http://plantuml.sourceforge.net
37
39
  :uri-py-plantuml: https://code.google.com/p/asciidoc-plantuml/
38
40
  :uri-rackdiag: http://blockdiag.com/en/nwdiag/index.html
@@ -40,6 +42,7 @@ ifndef::env-site[:status:]
40
42
  :uri-shaape: https://github.com/christiangoltz/shaape
41
43
  :uri-smcat: https://github.com/sverweij/state-machine-cat
42
44
  :uri-svgbob: https://github.com/ivanceras/svgbobrus
45
+ :uri-symbolator: https://github.com/kevinpt/symbolator
43
46
  :uri-syntrax: https://kevinpt.github.io/syntrax/
44
47
  :uri-umlet: http://www.umlet.com/
45
48
  :uri-vega: https://vega.github.io/vega/
@@ -50,7 +53,7 @@ ifndef::env-site[:status:]
50
53
 
51
54
  Asciidoctor Diagram is a set of Asciidoctor extensions that enable you to add diagrams, which you describe using plain text, to your AsciiDoc document.
52
55
 
53
- 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-erd}[Erd], {uri-gnuplot}[Gnuplot], {uri-dot}[GraphViz], {uri-mermaid}[Mermaid], {uri-mscgen}[Msc], {uri-nomnoml}[Nomnoml], {uri-plantuml}[PlantUML], {uri-shaape}[Shaape], {uri-smcat}[State Machine Cat], {uri-svgbob}[SvgBob], {uri-syntrax}[Syntrax], {uri-umlet}[UMLet], {uri-vega}[Vega], {uri-vegalite}[Vega-Lite] and {uri-wavedrom}[WaveDrom] syntax.
56
+ 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.
54
57
 
55
58
  Each extension runs the diagram processor to generate an SVG, PNG, or TXT file from the input text.
56
59
  The generated file is then inserted into your converted document.
@@ -126,6 +129,7 @@ The following diagram types and output formats are available:
126
129
  |{uri-bpmn}[bpmn] | |{check}|{check}|{check}|
127
130
  |{uri-bytefield}[bytefield] | | | |{check}|
128
131
  |{uri-ditaa}[ditaa] | | |{check}|{check}|
132
+ |{uri-dpic}[dpic] | | | |{check}|
129
133
  |{uri-erd}[erd] | | |{check}|{check}|
130
134
  |{uri-gnuplot}[gnuplot] |{check}| |{check}|{check}|{check}
131
135
  |{uri-dot}[graphviz] | |{check}|{check}|{check}|
@@ -135,12 +139,14 @@ The following diagram types and output formats are available:
135
139
  |{uri-nomnoml}[nomnoml] | | | |{check}|
136
140
  |{uri-nwdiag}[nwdiag] | |{check}|{check}|{check}|
137
141
  |{uri-packetdiag}[packetdiag]| |{check}|{check}|{check}|
142
+ |{uri-pikchr}[pikchr] | | | |{check}|
138
143
  |{uri-plantuml}[plantuml] | | |{check}|{check}|{check}
139
144
  |{uri-rackdiag}[rackdiag] | |{check}|{check}|{check}|
140
145
  |{uri-seqdiag}[seqdiag] | |{check}|{check}|{check}|
141
146
  |{uri-shaape}[shaape] | | |{check}|{check}|
142
147
  |{uri-smcat}[smcat] | | | |{check}|
143
148
  |{uri-svgbob}[svgbob] | | | |{check}|
149
+ |{uri-symbolator}[symbolator]| |{check}|{check}|{check}|
144
150
  |{uri-syntrax}[syntrax] | |{check}|{check}|{check}|
145
151
  |{uri-umlet}[umlet] |{check}|{check}|{check}|{check}|
146
152
  |{uri-vega}[vega] | | |{check}|{check}|
@@ -257,7 +263,7 @@ or load and register each extension individually.
257
263
  require 'asciidoctor-diagram/<extension_name>'
258
264
  ----
259
265
 
260
- `<extension_name>` can be one of `a2s`, `blockdiag`, `bytefield`, `ditaa`, `erd`, `gnuplot`, `graphviz`, `meme`, `mermaid`, `msc`, `plantuml`, `shaape`, `smcat`, `svgbob`, `syntrax`, `umlet`, `vega` or `wavedrom`.
266
+ `<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`.
261
267
 
262
268
  Requiring one or more of these files will automatically register the extensions for all processed documents.
263
269
 
@@ -306,21 +312,24 @@ The following table lists the tools that are required for each diagram type, the
306
312
  |bpmn |{uri-bpmn}[bpmn-js-cmd] |`bpmn`
307
313
  |bytefield |{uri-bytefield}[bytefield-svg] |`bytefield-svg`
308
314
  |ditaa |{uri-java}[Java] |`java`
315
+ |dpic |{uri-dpic}[dpic] |`dpic`
309
316
  |erd |{uri-erd}[Erd] |`erd`
310
317
  |gnuplot |{uri-gnuplot}[Gnuplot] |`gnuplot`
311
318
  |graphviz |{uri-graphviz}[GraphViz] |`dot` or `graphvizdot`
312
319
  |meme |{uri-imagemagick}[ImageMagick] |`convert` and `identify`
313
- |mermaid |{uri-mermaid}[Mermaid.cli] |`mermaid`
320
+ |mermaid |{uri-mermaid}[Mermaid.cli] |`mmdc`
314
321
  |msc |{uri-mscgen}[Mscgen] |`mscgen`
315
322
  |nomnoml |{uri-nomnoml}[Nomnoml] |`nomnoml`
316
323
  |nwdiag |{uri-nwdiag}[NwDiag] |`nwdiag`
317
324
  |packetdiag |{uri-nwdiag}[NwDiag] |`packetdiag`
325
+ |pikchr |{uri-pikchr}[Pikchr] |`pikchr`
318
326
  |plantuml |{uri-java}[Java] |`java`
319
327
  |rackdiag |{uri-nwdiag}[NwDiag] |`rackdiag`
320
328
  |seqdiag |{uri-seqdiag}[SeqDiag] |`seqdiag`
321
329
  |shaape |{uri-shaape}[Shaape] |`shaape`
322
330
  |smcat |{uri-smcat}[State Machine Cat] |`smcat`
323
331
  |svgbob |{uri-svgbob}[SvgBob] |`svgbob`
332
+ |symbolator |{uri-symbolator}[Symbolator] |`symbolator`
324
333
  |syntrax |{uri-syntrax}[Syntrax] |`syntrax`
325
334
  |umlet |{uri-umlet}[Umlet] |`umlet`
326
335
  |vega |{uri-vega}[vg2png] and/or {uri-vega}[vg2png] |`vg2png` and `vg2svg`
@@ -3,6 +3,7 @@ require_relative 'asciidoctor-diagram/blockdiag'
3
3
  require_relative 'asciidoctor-diagram/bpmn'
4
4
  require_relative 'asciidoctor-diagram/bytefield'
5
5
  require_relative 'asciidoctor-diagram/ditaa'
6
+ require_relative 'asciidoctor-diagram/dpic'
6
7
  require_relative 'asciidoctor-diagram/erd'
7
8
  require_relative 'asciidoctor-diagram/gnuplot'
8
9
  require_relative 'asciidoctor-diagram/graphviz'
@@ -11,11 +12,13 @@ require_relative 'asciidoctor-diagram/meme'
11
12
  require_relative 'asciidoctor-diagram/mermaid'
12
13
  require_relative 'asciidoctor-diagram/msc'
13
14
  require_relative 'asciidoctor-diagram/nomnoml'
15
+ require_relative 'asciidoctor-diagram/pikchr'
14
16
  require_relative 'asciidoctor-diagram/plantuml'
15
17
  require_relative 'asciidoctor-diagram/salt'
16
18
  require_relative 'asciidoctor-diagram/shaape'
17
19
  require_relative 'asciidoctor-diagram/smcat'
18
20
  require_relative 'asciidoctor-diagram/svgbob'
21
+ require_relative 'asciidoctor-diagram/symbolator'
19
22
  require_relative 'asciidoctor-diagram/syntrax'
20
23
  require_relative 'asciidoctor-diagram/tikz'
21
24
  require_relative 'asciidoctor-diagram/umlet'
@@ -175,7 +175,8 @@ module Asciidoctor
175
175
 
176
176
  metadata = source.create_image_metadata
177
177
  metadata[:options] = options
178
- metadata[:width], metadata[:height] = params[:decoder].get_image_size(result)
178
+
179
+ result, metadata[:width], metadata[:height] = params[:decoder].post_process_image(result)
179
180
 
180
181
  FileUtils.mkdir_p(File.dirname(image_file)) unless Dir.exist?(File.dirname(image_file))
181
182
  File.open(image_file, 'wb') {|f| f.write result}
@@ -184,12 +185,6 @@ module Asciidoctor
184
185
  File.open(metadata_file, 'w') {|f| JSON.dump(metadata, f)}
185
186
  end
186
187
 
187
- image_attributes['target'] = source.attr('data-uri', nil, true) ? image_file : image_name
188
- if format == :svg
189
- svg_type = source.attr('svg-type', nil, name) || source.attr('svg-type', nil, DIAGRAM_PREFIX)
190
- image_attributes['opts'] = svg_type if svg_type && svg_type != 'static'
191
- end
192
-
193
188
  scale = image_attributes['scale']
194
189
  if scalematch = /(\d+(?:\.\d+))/.match(scale)
195
190
  scale_factor = scalematch[1].to_f
@@ -207,25 +202,44 @@ module Asciidoctor
207
202
  end
208
203
  end
209
204
 
210
- image_attributes['alt'] ||= if title_text = image_attributes['title']
211
- title_text
212
- elsif target = image_attributes['target']
213
- (File.basename(target, File.extname(target)) || '').tr '_-', ' '
214
- else
215
- 'Diagram'
216
- end
205
+ parent.document.register(:images, image_name)
206
+
207
+ node = Asciidoctor::Block.new parent, :image, :content_model => :empty, :attributes => image_attributes
217
208
 
218
- image_attributes['alt'] = parent.sub_specialchars image_attributes['alt']
209
+ alt_text = node.attr('alt')
210
+ alt_text ||= if title_text = image_attributes['title']
211
+ title_text
212
+ elsif target = image_attributes['target']
213
+ (File.basename(target, File.extname(target)) || '').tr '_-', ' '
214
+ else
215
+ 'Diagram'
216
+ end
217
+ alt_text = parent.sub_specialchars(alt_text)
219
218
 
220
- parent.document.register(:images, image_name)
221
- if (scaledwidth = image_attributes['scaledwidth'])
219
+ node.set_attr('alt', alt_text)
220
+
221
+ if (scaledwidth = node.attr('scaledwidth'))
222
222
  # append % to scaledwidth if ends in number (no units present)
223
223
  if DIGIT_CHAR_RANGE.include?((scaledwidth[-1] || 0).ord)
224
- image_attributes['scaledwidth'] = %(#{scaledwidth}%)
224
+ node.set_attr('scaledwidth', %(#{scaledwidth}%))
225
+ end
226
+ end
227
+
228
+ node.set_attr('target', source.attr('data-uri', nil, true) ? image_file : image_name)
229
+
230
+ if format == :svg
231
+ svg_type = source.attr('svg-type', nil, name) || source.attr('svg-type', nil, DIAGRAM_PREFIX)
232
+ case svg_type
233
+ when nil, 'static'
234
+ when 'inline', 'interactive'
235
+ node.set_option(svg_type)
236
+ node.set_attr('target', image_file)
237
+ else
238
+ raise "Unsupported SVG type: #{svg_type}"
225
239
  end
226
240
  end
227
241
 
228
- Asciidoctor::Block.new parent, :image, :content_model => :empty, :attributes => image_attributes
242
+ node
229
243
  end
230
244
 
231
245
  def scale(size, factor)
@@ -1,3 +1,4 @@
1
+ require 'asciidoctor/logging'
1
2
  require_relative 'util/which'
2
3
 
3
4
  module Asciidoctor
@@ -5,6 +6,8 @@ module Asciidoctor
5
6
  # This module describes the duck-typed interface that diagram sources must implement. Implementations
6
7
  # may include this module but it is not required.
7
8
  module DiagramSource
9
+ include Asciidoctor::Logging
10
+
8
11
  def image_name
9
12
  raise NotImplementedError.new
10
13
  end
@@ -75,14 +78,42 @@ module Asciidoctor
75
78
  if config.key? cmd_var
76
79
  cmd_path = config[cmd_var]
77
80
  else
78
- cmd_path = attr_names.map { |attr_name| attr(attr_name, nil, true) }.find { |attr| !attr.nil? }
79
-
80
- unless cmd_path && File.executable?(cmd_path)
81
- cmd_paths = cmd_names.map do |c|
82
- ::Asciidoctor::Diagram::Which.which(c, :path => options[:path])
83
- end
84
-
85
- cmd_path = cmd_paths.reject { |c| c.nil? }.first
81
+ logger.debug "Finding '#{cmd}' in attributes"
82
+ cmd_path = attr_names.map { |attr_name|
83
+ attr = attr(attr_name, nil, true)
84
+ if logger.debug? && attr
85
+ logger.debug "Found value '#{attr}' in attribute '#{attr_name}'" if attr
86
+ end
87
+ attr
88
+ }
89
+ .reject { |attr| attr.nil? }
90
+ .map { |attr|
91
+ expanded = File.expand_path(attr)
92
+ if logger.debug? && attr != expanded
93
+ logger.debug "Expanded '#{attr}' to '#{expanded}'"
94
+ end
95
+ expanded
96
+ }
97
+ .select { |path|
98
+ executable = File.executable?(path)
99
+ if logger.debug?
100
+ logger.debug "Is '#{path}' executable? #{executable}"
101
+ end
102
+ executable
103
+ }
104
+ .first
105
+
106
+ unless cmd_path
107
+ logger.debug "Finding '#{cmd}' in environment"
108
+ cmd_path = cmd_names.map { |c|
109
+ path = ::Asciidoctor::Diagram::Which.which(c, :path => options[:path])
110
+ if logger.debug? && path
111
+ logger.debug "Found '#{path}' in environment"
112
+ end
113
+ path
114
+ }
115
+ .reject { |path| path.nil? }
116
+ .first
86
117
  end
87
118
 
88
119
  config[cmd_var] = cmd_path
@@ -0,0 +1,7 @@
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'dpic/extension'
3
+
4
+ Asciidoctor::Extensions.register do
5
+ block Asciidoctor::Diagram::DpicBlockProcessor, :dpic
6
+ block_macro Asciidoctor::Diagram::DpicBlockMacroProcessor, :dpic
7
+ end
@@ -0,0 +1,30 @@
1
+ require_relative '../diagram_converter'
2
+ require_relative '../util/cli_generator'
3
+ require_relative '../util/platform'
4
+
5
+ module Asciidoctor
6
+ module Diagram
7
+ # @private
8
+ class DpicConverter
9
+ include DiagramConverter
10
+ include CliGenerator
11
+
12
+
13
+ def supported_formats
14
+ [:svg]
15
+ end
16
+
17
+ def convert(source, format, options)
18
+ dpic_path = source.find_command('dpic')
19
+
20
+ code = source.to_s
21
+ code.prepend ".PS\n" unless code.start_with?(".PS\n")
22
+ code << "\n.PE" unless code.start_with?("\n.PE")
23
+
24
+ generate_file_stdout(dpic_path, format.to_s, code) do |tool_path, input_path|
25
+ [tool_path, "-v", "-z", input_path]
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,14 @@
1
+ require_relative 'converter'
2
+ require_relative '../diagram_processor'
3
+
4
+ module Asciidoctor
5
+ module Diagram
6
+ class DpicBlockProcessor < DiagramBlockProcessor
7
+ use_converter DpicConverter
8
+ end
9
+
10
+ class DpicBlockMacroProcessor < DiagramBlockMacroProcessor
11
+ use_converter DpicConverter
12
+ end
13
+ end
14
+ end
@@ -51,6 +51,7 @@ module Asciidoctor
51
51
  path << '/' unless path.end_with? '/'
52
52
  path << format.to_s
53
53
  path << '/' << data
54
+ uri.path = path
54
55
  when :kroki_io
55
56
  compressed = Zlib.deflate(code, Zlib::BEST_COMPRESSION)
56
57
  data = Base64.urlsafe_encode64(compressed)
@@ -60,17 +61,36 @@ module Asciidoctor
60
61
  path << options[:block_name].to_s
61
62
  path << '/' << format.to_s
62
63
  path << '/' << data
64
+ uri.path = path
63
65
  else
64
66
  raise "Unsupported server type: " + @type
65
67
  end
66
68
 
69
+ get_uri(uri)
70
+ end
71
+
72
+ private
73
+
74
+ def get_uri(uri, attempt = 1)
75
+ if attempt >= 10
76
+ raise "Too many redirects"
77
+ end
78
+
67
79
  Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme.downcase == 'https') do |http|
68
- response = http.request_get path
80
+ response = http.request_get uri.path
69
81
  case response
70
- when Net::HTTPSuccess
71
- response.body
72
- else
73
- response.value
82
+ when Net::HTTPSuccess
83
+ response.body
84
+ when Net::HTTPRedirection then
85
+ location = response['Location']
86
+ new_uri = URI.parse(location)
87
+ if new_uri.relative?
88
+ get_uri(uri + location, attempt + 1)
89
+ else
90
+ get_uri(new_uri, attempt + 1)
91
+ end
92
+ else
93
+ response.value
74
94
  end
75
95
  end
76
96
  end
@@ -57,7 +57,8 @@ module Asciidoctor
57
57
  opts[:width] = options[:width]
58
58
 
59
59
  mmdc = source.find_command('mmdc', :raise_on_error => false)
60
- if mmdc
60
+ node = source.find_command('node', :raise_on_error => false)
61
+ if mmdc && node
61
62
  opts[:height] = options[:height]
62
63
  opts[:theme] = options[:theme]
63
64
  opts[:background] = options[:background]
@@ -65,7 +66,7 @@ module Asciidoctor
65
66
  if config
66
67
  opts[:config] = source.resolve_path(config)
67
68
  end
68
- run_mmdc(mmdc, source, format, opts)
69
+ run_mmdc(node, mmdc, source, format, opts)
69
70
  else
70
71
  mermaid = source.find_command('mermaid')
71
72
  run_mermaid(mermaid, source, format, opts)
@@ -73,9 +74,9 @@ module Asciidoctor
73
74
  end
74
75
 
75
76
  private
76
- def run_mmdc(mmdc, source, format, options = {})
77
- generate_file(mmdc, 'mmd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
78
- args = [tool_path, '-i', Platform.native_path(input_path), '-o', Platform.native_path(output_path)]
77
+ def run_mmdc(node, mmdc, source, format, options = {})
78
+ generate_file(node, 'mmd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
79
+ args = [tool_path, '--unhandled-rejections=strict', mmdc, '-i', Platform.native_path(input_path), '-o', Platform.native_path(output_path)]
79
80
 
80
81
  if options[:css]
81
82
  args << '--cssFile' << Platform.native_path(options[:css])
@@ -0,0 +1,7 @@
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'pikchr/extension'
3
+
4
+ Asciidoctor::Extensions.register do
5
+ block Asciidoctor::Diagram::PikchrBlockProcessor, :pikchr
6
+ block_macro Asciidoctor::Diagram::PikchrBlockMacroProcessor, :pikchr
7
+ end
@@ -0,0 +1,26 @@
1
+ require_relative '../diagram_converter'
2
+ require_relative '../util/cli_generator'
3
+ require_relative '../util/platform'
4
+
5
+ module Asciidoctor
6
+ module Diagram
7
+ # @private
8
+ class PikchrConverter
9
+ include DiagramConverter
10
+ include CliGenerator
11
+
12
+
13
+ def supported_formats
14
+ [:svg]
15
+ end
16
+
17
+ def convert(source, format, options)
18
+ pikchr_path = source.find_command('pikchr')
19
+
20
+ generate_file_stdout(pikchr_path, format.to_s, source.to_s) do |tool_path, input_path|
21
+ [tool_path, "--svg-only", input_path]
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,14 @@
1
+ require_relative 'converter'
2
+ require_relative '../diagram_processor'
3
+
4
+ module Asciidoctor
5
+ module Diagram
6
+ class PikchrBlockProcessor < DiagramBlockProcessor
7
+ use_converter PikchrConverter
8
+ end
9
+
10
+ class PikchrBlockMacroProcessor < DiagramBlockMacroProcessor
11
+ use_converter PikchrConverter
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'symbolator/extension'
3
+
4
+ Asciidoctor::Extensions.register do
5
+ block Asciidoctor::Diagram::SymbolatorBlockProcessor, :symbolator
6
+ block_macro Asciidoctor::Diagram::SymbolatorBlockMacroProcessor, :symbolator
7
+ end
@@ -0,0 +1,23 @@
1
+ require_relative '../diagram_converter'
2
+ require_relative '../util/cli_generator'
3
+ require_relative '../util/platform'
4
+
5
+ module Asciidoctor
6
+ module Diagram
7
+ # @private
8
+ class SymbolatorConverter
9
+ include DiagramConverter
10
+ include CliGenerator
11
+
12
+ def supported_formats
13
+ [:png, :pdf, :svg]
14
+ end
15
+
16
+ def convert(source, format, options)
17
+ generate_stdin(source.find_command('symbolator'), format.to_s, source.to_s) do |tool_path, output_path|
18
+ [tool_path, "-i-", "-o#{Platform.native_path(output_path)}", "-f#{format.to_s}"]
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ require_relative '../diagram_processor'
2
+ require_relative 'converter'
3
+
4
+ module Asciidoctor
5
+ module Diagram
6
+ class SymbolatorBlockProcessor < DiagramBlockProcessor
7
+ use_converter SymbolatorConverter
8
+ end
9
+
10
+ class SymbolatorBlockMacroProcessor < DiagramBlockMacroProcessor
11
+ use_converter SymbolatorConverter
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,4 @@
1
+ require 'asciidoctor/logging'
1
2
  require 'tempfile'
2
3
  require_relative 'cli'
3
4
 
@@ -5,6 +6,8 @@ module Asciidoctor
5
6
  module Diagram
6
7
  # @private
7
8
  module CliGenerator
9
+ include Asciidoctor::Logging
10
+
8
11
  def generate_stdin(tool, format, code)
9
12
  tool_name = File.basename(tool)
10
13
 
@@ -51,6 +54,20 @@ module Asciidoctor
51
54
  end
52
55
  end
53
56
 
57
+ def generate_file_stdout(tool, input_ext, code)
58
+ tool_name = File.basename(tool)
59
+
60
+ source_file = Tempfile.new([tool_name, ".#{input_ext}"])
61
+ begin
62
+ File.write(source_file.path, code)
63
+
64
+ opts = yield tool, source_file.path
65
+ generate(opts, :stdout)
66
+ ensure
67
+ source_file.unlink
68
+ end
69
+ end
70
+
54
71
  private
55
72
  def generate(opts, target_file, open3_opts = {})
56
73
  case opts
@@ -64,6 +81,7 @@ module Asciidoctor
64
81
  raise "Block passed to generate_file should return an Array or a Hash"
65
82
  end
66
83
 
84
+ logger.debug "Executing #{args} with options #{open3_opts}"
67
85
  result = ::Asciidoctor::Diagram::Cli.run(*args, open3_opts)
68
86
 
69
87
  data = target_file == :stdout ? result[:out] : read_result(target_file, out_file)
@@ -7,14 +7,14 @@ module Asciidoctor
7
7
  GIF87A_SIGNATURE = 'GIF87a'.force_encoding(Encoding::ASCII_8BIT)
8
8
  GIF89A_SIGNATURE = 'GIF89a'.force_encoding(Encoding::ASCII_8BIT)
9
9
 
10
- def self.get_image_size(data)
10
+ def self.post_process_image(data)
11
11
  bio = BinaryIO.new(data)
12
12
  gif_signature = bio.read_string(6)
13
13
  raise "Invalid GIF signature" unless gif_signature == GIF87A_SIGNATURE || gif_signature == GIF89A_SIGNATURE
14
14
 
15
15
  width = bio.read_uint16_le
16
16
  height = bio.read_uint16_le
17
- [width, height]
17
+ [data, width, height]
18
18
  end
19
19
  end
20
20
  end
@@ -2,8 +2,8 @@ module Asciidoctor
2
2
  module Diagram
3
3
  # @private
4
4
  module PDF
5
- def self.get_image_size(_)
6
- nil
5
+ def self.post_process_image(data)
6
+ [data, nil, nil]
7
7
  end
8
8
  end
9
9
  end
@@ -6,7 +6,7 @@ module Asciidoctor
6
6
  module PNG
7
7
  PNG_SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10].pack('CCCCCCCC')
8
8
 
9
- def self.get_image_size(data)
9
+ def self.post_process_image(data)
10
10
  bio = BinaryIO.new(data)
11
11
  png_signature = bio.read_string(8)
12
12
  raise "Invalid PNG signature" unless png_signature == PNG_SIGNATURE
@@ -18,7 +18,7 @@ module Asciidoctor
18
18
 
19
19
  width = bio.read_uint32_be
20
20
  height = bio.read_uint32_be
21
- [width, height]
21
+ [data, width, height]
22
22
  end
23
23
  end
24
24
  end
@@ -1,34 +1,53 @@
1
1
  require_relative 'binaryio'
2
+ require 'rexml/document'
3
+ require 'bigdecimal'
4
+ require 'bigdecimal/util'
2
5
 
3
6
  module Asciidoctor
4
7
  module Diagram
5
8
  # @private
6
9
  module SVG
7
- def self.get_image_size(data)
8
- if m = START_TAG_REGEX.match(data)
9
- start_tag = m[0]
10
- if (w = WIDTH_REGEX.match(start_tag)) && (h = HEIGHT_REGEX.match(start_tag))
11
- width = w[:value].to_i * to_px_factor(w[:unit])
12
- height = h[:value].to_i * to_px_factor(h[:unit])
13
- return [width.to_i, height.to_i]
14
- end
15
-
16
- if v = VIEWBOX_REGEX.match(start_tag)
17
- width = v[:width]
18
- height = v[:height]
19
- return [width.to_i, height.to_i]
20
- end
10
+ def self.post_process_image(data)
11
+ svg = REXML::Document.new(data)
12
+
13
+ root = svg.root
14
+
15
+ unless root.attributes['xmlns']
16
+ root.add_attribute('xmlns', 'http://www.w3.org/2000/svg')
17
+ end
18
+
19
+ unless root.attributes['preserveAspectRatio']
20
+ root.add_attribute('preserveAspectRatio', 'xMidYMid meet')
21
+ end
22
+
23
+ width = nil
24
+ height = nil
25
+
26
+ if (w = WIDTH_HEIGHT_REGEX.match(root.attributes['width'])) && (h = WIDTH_HEIGHT_REGEX.match(root.attributes['height']))
27
+ width = w[:value].to_d * to_px_factor(w[:unit])
28
+ height = h[:value].to_d * to_px_factor(h[:unit])
29
+ end
30
+
31
+ viewbox = root.attributes['viewBox']
32
+ if (v = VIEWBOX_REGEX.match(viewbox)) && width.nil? && height.nil?
33
+ width = v[:width].to_d
34
+ height = v[:height].to_d
21
35
  end
22
36
 
23
- nil
37
+ if viewbox.nil? && width && height
38
+ root.add_attribute('viewBox', "0 0 #{width.to_s('F')} #{height.to_s('F')}")
39
+ end
40
+
41
+ patched_svg = ""
42
+ svg.write(:output => patched_svg, :indent => 2)
43
+
44
+ [patched_svg, width, height]
24
45
  end
25
46
 
26
47
  private
27
48
 
28
- START_TAG_REGEX = /<svg[^>]*>/
29
- WIDTH_REGEX = /width="(?<value>\d+(?:\.\d+)?)(?<unit>[a-zA-Z]+)?"/
30
- HEIGHT_REGEX = /height="(?<value>\d+(?:\.\d+)?)(?<unit>[a-zA-Z]+)?"/
31
- VIEWBOX_REGEX = /viewBox="\d+(?:\.\d+)? \d+(?:\.\d+)? (?<width>\d+(?:\.\d+)?) (?<height>\d+(?:\.\d+)?)"/
49
+ WIDTH_HEIGHT_REGEX = /^\s*(?<value>\d+(?:\.\d+)?)\s*(?<unit>[a-zA-Z]+)?\s*$/
50
+ VIEWBOX_REGEX = /^\s*\d+(?:\.\d+)?\s*\d+(?:\.\d+)?\s*(?<width>\d+(?:\.\d+)?)\s*(?<height>\d+(?:\.\d+)?)\s*$/
32
51
 
33
52
  def self.to_px_factor(unit)
34
53
  case unit
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Diagram
3
- VERSION = "2.0.2"
3
+ VERSION = "2.0.3"
4
4
  end
5
5
  end
@@ -0,0 +1,74 @@
1
+ require_relative 'test_helper'
2
+
3
+ code = <<-eos
4
+ arrow "$u$" above
5
+ S: circle rad 10/72.27 # 10 pt
6
+ line right 0.35
7
+ G: box "$G(s)$"
8
+ arrow "$y$" above
9
+ line -> down G.ht from last arrow then left last arrow.c.x-S.x then to S.s
10
+ "$-\;$" below rjust
11
+ eos
12
+
13
+ describe Asciidoctor::Diagram::DpicBlockMacroProcessor, :broken_on_travis, :broken_on_windows do
14
+ it "should generate SVG images when format is set to 'svg'" do
15
+ File.write('dpic.txt', code)
16
+
17
+ doc = <<-eos
18
+ = Hello, Dpic!
19
+ Doc Writer <doc@example.com>
20
+
21
+ == First Section
22
+
23
+ dpic::dpic.txt[format="svg"]
24
+ eos
25
+
26
+ d = load_asciidoc doc
27
+ expect(d).to_not be_nil
28
+
29
+ b = d.find { |bl| bl.context == :image }
30
+ expect(b).to_not be_nil
31
+
32
+ expect(b.content_model).to eq :empty
33
+
34
+ target = b.attributes['target']
35
+ expect(target).to_not be_nil
36
+ expect(target).to match(/\.svg/)
37
+ expect(File.exist?(target)).to be true
38
+
39
+ expect(b.attributes['width']).to_not be_nil
40
+ expect(b.attributes['height']).to_not be_nil
41
+ end
42
+ end
43
+
44
+ describe Asciidoctor::Diagram::DpicBlockProcessor, :broken_on_travis, :broken_on_windows do
45
+ it "should generate SVG images when format is set to 'svg'" do
46
+ doc = <<-eos
47
+ = Hello, Dpic!
48
+ Doc Writer <doc@example.com>
49
+
50
+ == First Section
51
+
52
+ [dpic, format="svg"]
53
+ ----
54
+ #{code}
55
+ ----
56
+ eos
57
+
58
+ d = load_asciidoc doc
59
+ expect(d).to_not be_nil
60
+
61
+ b = d.find { |bl| bl.context == :image }
62
+ expect(b).to_not be_nil
63
+
64
+ expect(b.content_model).to eq :empty
65
+
66
+ target = b.attributes['target']
67
+ expect(target).to_not be_nil
68
+ expect(target).to match(/\.svg/)
69
+ expect(File.exist?(target)).to be true
70
+
71
+ expect(b.attributes['width']).to_not be_nil
72
+ expect(b.attributes['height']).to_not be_nil
73
+ end
74
+ end
@@ -0,0 +1,106 @@
1
+ require_relative 'test_helper'
2
+
3
+ code = <<-eos
4
+ # Change from the original:
5
+ # * Expand the macro by hand, as Pikchr does not support
6
+ # macros
7
+ #
8
+ #define ndblock {
9
+ # box wid boxwid/2 ht boxht/2
10
+ # down; box same with .t at bottom of last box; box same
11
+ #}
12
+ boxht = .2; boxwid = .3; circlerad = .3; dx = 0.05
13
+ down; box; box; box; box ht 3*boxht "." "." "."
14
+ L: box; box; box invis wid 2*boxwid "hashtab:" with .e at 1st box .w
15
+ right
16
+ Start: box wid .5 with .sw at 1st box.ne + (.4,.2) "..."
17
+ N1: box wid .2 "n1"; D1: box wid .3 "d1"
18
+ N3: box wid .4 "n3"; D3: box wid .3 "d3"
19
+ box wid .4 "..."
20
+ N2: box wid .5 "n2"; D2: box wid .2 "d2"
21
+ arrow right from 2nd box
22
+ #ndblock
23
+ box wid boxwid/2 ht boxht/2
24
+ down; box same with .t at bottom of last box; box same
25
+ spline -> right .2 from 3rd last box then to N1.sw + (dx,0)
26
+ spline -> right .3 from 2nd last box then to D1.sw + (dx,0)
27
+ arrow right from last box
28
+ #ndblock
29
+ box wid boxwid/2 ht boxht/2
30
+ down; box same with .t at bottom of last box; box same
31
+ spline -> right .2 from 3rd last box to N2.sw-(dx,.2) to N2.sw+(dx,0)
32
+ spline -> right .3 from 2nd last box to D2.sw-(dx,.2) to D2.sw+(dx,0)
33
+ arrow right 2*linewid from L
34
+ #ndblock
35
+ box wid boxwid/2 ht boxht/2
36
+ down; box same with .t at bottom of last box; box same
37
+ spline -> right .2 from 3rd last box to N3.sw + (dx,0)
38
+ spline -> right .3 from 2nd last box to D3.sw + (dx,0)
39
+ circlerad = .3
40
+ circle invis "ndblock" at last box.e + (1.2,.2)
41
+ arrow dashed from last circle.w to 5/8<last circle.w,2nd last box> chop
42
+ box invis wid 2*boxwid "ndtable:" with .e at Start.w
43
+ eos
44
+
45
+ describe Asciidoctor::Diagram::PikchrBlockMacroProcessor, :broken_on_travis, :broken_on_windows do
46
+ it "should generate SVG images when format is set to 'svg'" do
47
+ File.write('pikchr.txt', code)
48
+
49
+ doc = <<-eos
50
+ = Hello, Pikchr!
51
+ Doc Writer <doc@example.com>
52
+
53
+ == First Section
54
+
55
+ pikchr::pikchr.txt[format="svg"]
56
+ eos
57
+
58
+ d = load_asciidoc doc
59
+ expect(d).to_not be_nil
60
+
61
+ b = d.find { |bl| bl.context == :image }
62
+ expect(b).to_not be_nil
63
+
64
+ expect(b.content_model).to eq :empty
65
+
66
+ target = b.attributes['target']
67
+ expect(target).to_not be_nil
68
+ expect(target).to match(/\.svg/)
69
+ expect(File.exist?(target)).to be true
70
+
71
+ expect(b.attributes['width']).to_not be_nil
72
+ expect(b.attributes['height']).to_not be_nil
73
+ end
74
+ end
75
+
76
+ describe Asciidoctor::Diagram::ErdBlockProcessor, :broken_on_travis, :broken_on_windows do
77
+ it "should generate SVG images when format is set to 'svg'" do
78
+ doc = <<-eos
79
+ = Hello, Pikchr!
80
+ Doc Writer <doc@example.com>
81
+
82
+ == First Section
83
+
84
+ [pikchr, format="svg"]
85
+ ----
86
+ #{code}
87
+ ----
88
+ eos
89
+
90
+ d = load_asciidoc doc
91
+ expect(d).to_not be_nil
92
+
93
+ b = d.find { |bl| bl.context == :image }
94
+ expect(b).to_not be_nil
95
+
96
+ expect(b.content_model).to eq :empty
97
+
98
+ target = b.attributes['target']
99
+ expect(target).to_not be_nil
100
+ expect(target).to match(/\.svg/)
101
+ expect(File.exist?(target)).to be true
102
+
103
+ expect(b.attributes['width']).to_not be_nil
104
+ expect(b.attributes['height']).to_not be_nil
105
+ end
106
+ end
@@ -343,7 +343,7 @@ User --> (Use the application) : Label
343
343
  expect(target).to match(/\.svg/)
344
344
  expect(File.exist?(target)).to be true
345
345
 
346
- expect(b.attributes['opts']).to eq('inline')
346
+ expect(b.option?('inline')).to be_truthy
347
347
 
348
348
  expect(b.attributes['width']).to_not be_nil
349
349
  expect(b.attributes['height']).to_not be_nil
@@ -379,7 +379,7 @@ User --> (Use the application) : Label
379
379
  expect(target).to match(/\.svg/)
380
380
  expect(File.exist?(target)).to be true
381
381
 
382
- expect(b.attributes['opts']).to eq('inline')
382
+ expect(b.option?('inline')).to be_truthy
383
383
 
384
384
  expect(b.attributes['width']).to_not be_nil
385
385
  expect(b.attributes['height']).to_not be_nil
@@ -460,7 +460,7 @@ skinparam ArrowColor #DEADBE
460
460
  expect(File.exist?(target)).to be true
461
461
 
462
462
  svg = File.read(target, :encoding => Encoding::UTF_8)
463
- expect(svg).to match(/<path.*fill="#DEADBE"/)
463
+ expect(svg).to match(/<[^<]+ fill=["']#DEADBE["']/)
464
464
  end
465
465
 
466
466
  it 'should not regenerate images when source has not changed' do
@@ -0,0 +1,200 @@
1
+ require_relative 'test_helper'
2
+
3
+ code = <<-eos
4
+ library ieee;
5
+ use ieee.std_logic_1164.all;
6
+
7
+ package demo is
8
+ component demo_device is
9
+ generic (
10
+ SIZE : positive;
11
+ RESET_ACTIVE_LEVEL : std_ulogic := '1'
12
+ );
13
+ port (
14
+ --# {{clocks|}}
15
+ Clock : in std_ulogic;
16
+ Reset : in std_ulogic;
17
+
18
+ --# {{control|Named section}}
19
+ Enable : in std_ulogic;
20
+ Data_in : in std_ulogic_vector(SIZE-1 downto 0);
21
+ Data_out : out std_ulogic_vector(SIZE-1 downto 0)
22
+ );
23
+ end component;
24
+ end package;
25
+ eos
26
+
27
+ describe Asciidoctor::Diagram::SymbolatorBlockMacroProcessor, :broken_on_windows do
28
+ it "should generate PNG images when format is set to 'png'" do
29
+ File.write('symbolator.txt', code)
30
+
31
+ doc = <<-eos
32
+ = Hello, Symbolator!
33
+ Doc Writer <doc@example.com>
34
+
35
+ == First Section
36
+
37
+ symbolator::symbolator.txt[format="png"]
38
+ eos
39
+
40
+ d = load_asciidoc doc
41
+ expect(d).to_not be_nil
42
+
43
+ b = d.find { |bl| bl.context == :image }
44
+ expect(b).to_not be_nil
45
+
46
+ expect(b.content_model).to eq :empty
47
+
48
+ target = b.attributes['target']
49
+ expect(target).to_not be_nil
50
+ expect(target).to match(/\.png$/)
51
+ expect(File.exist?(target)).to be true
52
+
53
+ expect(b.attributes['width']).to_not be_nil
54
+ expect(b.attributes['height']).to_not be_nil
55
+ end
56
+
57
+ it "should generate SVG images when format is set to 'svg'" do
58
+ File.write('symbolator.txt', code)
59
+
60
+ doc = <<-eos
61
+ = Hello, Symbolator!
62
+ Doc Writer <doc@example.com>
63
+
64
+ == First Section
65
+
66
+ symbolator::symbolator.txt[format="svg"]
67
+ eos
68
+
69
+ d = load_asciidoc doc
70
+ expect(d).to_not be_nil
71
+
72
+ b = d.find { |bl| bl.context == :image }
73
+ expect(b).to_not be_nil
74
+
75
+ expect(b.content_model).to eq :empty
76
+
77
+ target = b.attributes['target']
78
+ expect(target).to_not be_nil
79
+ expect(target).to match(/\.svg/)
80
+ expect(File.exist?(target)).to be true
81
+
82
+ expect(b.attributes['width']).to_not be_nil
83
+ expect(b.attributes['height']).to_not be_nil
84
+ end
85
+
86
+ it "should generate PDF images when format is set to 'pdf'" do
87
+ File.write('symbolator.txt', code)
88
+
89
+ doc = <<-eos
90
+ = Hello, Symbolator!
91
+ Doc Writer <doc@example.com>
92
+
93
+ == First Section
94
+
95
+ symbolator::symbolator.txt[format="pdf"]
96
+ eos
97
+
98
+ d = load_asciidoc doc
99
+ expect(d).to_not be_nil
100
+
101
+ b = d.find { |bl| bl.context == :image }
102
+ expect(b).to_not be_nil
103
+
104
+ expect(b.content_model).to eq :empty
105
+
106
+ target = b.attributes['target']
107
+ expect(target).to_not be_nil
108
+ expect(target).to match(/\.pdf/)
109
+ expect(File.exist?(target)).to be true
110
+ end
111
+ end
112
+
113
+ describe Asciidoctor::Diagram::SymbolatorBlockProcessor, :broken_on_windows do
114
+ it "should generate PNG images when format is set to 'png'" do
115
+ doc = <<-eos
116
+ = Hello, Symbolator!
117
+ Doc Writer <doc@example.com>
118
+
119
+ == First Section
120
+
121
+ [symbolator, format="png"]
122
+ ----
123
+ #{code}
124
+ ----
125
+ eos
126
+
127
+ d = load_asciidoc doc
128
+ expect(d).to_not be_nil
129
+
130
+ b = d.find { |bl| bl.context == :image }
131
+ expect(b).to_not be_nil
132
+
133
+ expect(b.content_model).to eq :empty
134
+
135
+ target = b.attributes['target']
136
+ expect(target).to_not be_nil
137
+ expect(target).to match(/\.png$/)
138
+ expect(File.exist?(target)).to be true
139
+
140
+ expect(b.attributes['width']).to_not be_nil
141
+ expect(b.attributes['height']).to_not be_nil
142
+ end
143
+
144
+ it "should generate SVG images when format is set to 'svg'" do
145
+ doc = <<-eos
146
+ = Hello, Symbolator!
147
+ Doc Writer <doc@example.com>
148
+
149
+ == First Section
150
+
151
+ [symbolator, format="svg"]
152
+ ----
153
+ #{code}
154
+ ----
155
+ eos
156
+
157
+ d = load_asciidoc doc
158
+ expect(d).to_not be_nil
159
+
160
+ b = d.find { |bl| bl.context == :image }
161
+ expect(b).to_not be_nil
162
+
163
+ expect(b.content_model).to eq :empty
164
+
165
+ target = b.attributes['target']
166
+ expect(target).to_not be_nil
167
+ expect(target).to match(/\.svg/)
168
+ expect(File.exist?(target)).to be true
169
+
170
+ expect(b.attributes['width']).to_not be_nil
171
+ expect(b.attributes['height']).to_not be_nil
172
+ end
173
+
174
+ it "should generate PDF images when format is set to 'pdf'" do
175
+ doc = <<-eos
176
+ = Hello, Symbolator!
177
+ Doc Writer <doc@example.com>
178
+
179
+ == First Section
180
+
181
+ [symbolator, format="pdf"]
182
+ ----
183
+ #{code}
184
+ ----
185
+ eos
186
+
187
+ d = load_asciidoc doc
188
+ expect(d).to_not be_nil
189
+
190
+ b = d.find { |bl| bl.context == :image }
191
+ expect(b).to_not be_nil
192
+
193
+ expect(b.content_model).to eq :empty
194
+
195
+ target = b.attributes['target']
196
+ expect(target).to_not be_nil
197
+ expect(target).to match(/\.pdf/)
198
+ expect(File.exist?(target)).to be true
199
+ end
200
+ end
@@ -6,28 +6,6 @@ require 'stringio'
6
6
  require 'tmpdir'
7
7
 
8
8
  require_relative '../lib/asciidoctor-diagram'
9
- require_relative '../lib/asciidoctor-diagram/a2s/extension'
10
- require_relative '../lib/asciidoctor-diagram/blockdiag/extension'
11
- require_relative '../lib/asciidoctor-diagram/bytefield'
12
- require_relative '../lib/asciidoctor-diagram/ditaa/extension'
13
- require_relative '../lib/asciidoctor-diagram/erd/extension'
14
- require_relative '../lib/asciidoctor-diagram/gnuplot/extension'
15
- require_relative '../lib/asciidoctor-diagram/graphviz/extension'
16
- require_relative '../lib/asciidoctor-diagram/lilypond/extension'
17
- require_relative '../lib/asciidoctor-diagram/meme/extension'
18
- require_relative '../lib/asciidoctor-diagram/mermaid/extension'
19
- require_relative '../lib/asciidoctor-diagram/msc/extension'
20
- require_relative '../lib/asciidoctor-diagram/nomnoml/extension'
21
- require_relative '../lib/asciidoctor-diagram/plantuml/extension'
22
- require_relative '../lib/asciidoctor-diagram/shaape/extension'
23
- require_relative '../lib/asciidoctor-diagram/smcat/extension'
24
- require_relative '../lib/asciidoctor-diagram/svgbob/extension'
25
- require_relative '../lib/asciidoctor-diagram/syntrax/extension'
26
- require_relative '../lib/asciidoctor-diagram/tikz/extension'
27
- require_relative '../lib/asciidoctor-diagram/umlet/extension'
28
- require_relative '../lib/asciidoctor-diagram/vega/extension'
29
- require_relative '../lib/asciidoctor-diagram/wavedrom/extension'
30
-
31
9
  require_relative '../lib/asciidoctor-diagram/util/platform'
32
10
 
33
11
  module Asciidoctor
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-diagram
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pepijn Van Eeckhoudt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-13 00:00:00.000000000 Z
11
+ date: 2020-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -109,6 +109,9 @@ files:
109
109
  - lib/asciidoctor-diagram/ditaa.rb
110
110
  - lib/asciidoctor-diagram/ditaa/converter.rb
111
111
  - lib/asciidoctor-diagram/ditaa/extension.rb
112
+ - lib/asciidoctor-diagram/dpic.rb
113
+ - lib/asciidoctor-diagram/dpic/converter.rb
114
+ - lib/asciidoctor-diagram/dpic/extension.rb
112
115
  - lib/asciidoctor-diagram/erd.rb
113
116
  - lib/asciidoctor-diagram/erd/converter.rb
114
117
  - lib/asciidoctor-diagram/erd/extension.rb
@@ -135,6 +138,9 @@ files:
135
138
  - lib/asciidoctor-diagram/nomnoml.rb
136
139
  - lib/asciidoctor-diagram/nomnoml/converter.rb
137
140
  - lib/asciidoctor-diagram/nomnoml/extension.rb
141
+ - lib/asciidoctor-diagram/pikchr.rb
142
+ - lib/asciidoctor-diagram/pikchr/converter.rb
143
+ - lib/asciidoctor-diagram/pikchr/extension.rb
138
144
  - lib/asciidoctor-diagram/plantuml.rb
139
145
  - lib/asciidoctor-diagram/plantuml/converter.rb
140
146
  - lib/asciidoctor-diagram/plantuml/extension.rb
@@ -148,6 +154,9 @@ files:
148
154
  - lib/asciidoctor-diagram/svgbob.rb
149
155
  - lib/asciidoctor-diagram/svgbob/converter.rb
150
156
  - lib/asciidoctor-diagram/svgbob/extension.rb
157
+ - lib/asciidoctor-diagram/symbolator.rb
158
+ - lib/asciidoctor-diagram/symbolator/converter.rb
159
+ - lib/asciidoctor-diagram/symbolator/extension.rb
151
160
  - lib/asciidoctor-diagram/syntrax.rb
152
161
  - lib/asciidoctor-diagram/syntrax/converter.rb
153
162
  - lib/asciidoctor-diagram/syntrax/extension.rb
@@ -189,6 +198,7 @@ files:
189
198
  - spec/bpmn_spec.rb
190
199
  - spec/bytefield_spec.rb
191
200
  - spec/ditaa_spec.rb
201
+ - spec/dpic_spec.rb
192
202
  - spec/erd_spec.rb
193
203
  - spec/gnuplot_spec.rb
194
204
  - spec/graphviz_spec.rb
@@ -198,10 +208,12 @@ files:
198
208
  - spec/mermaid_spec.rb
199
209
  - spec/msc_spec.rb
200
210
  - spec/nomnoml_spec.rb
211
+ - spec/pikchr_spec.rb
201
212
  - spec/plantuml_spec.rb
202
213
  - spec/shaape_spec.rb
203
214
  - spec/smcat_spec.rb
204
215
  - spec/svgbob_spec.rb
216
+ - spec/symbolator_spec.rb
205
217
  - spec/syntrax_spec.rb
206
218
  - spec/test_helper.rb
207
219
  - spec/tikz_spec.rb
@@ -227,8 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
239
  - !ruby/object:Gem::Version
228
240
  version: '0'
229
241
  requirements: []
230
- rubyforge_project:
231
- rubygems_version: 2.7.6
242
+ rubygems_version: 3.0.1
232
243
  signing_key:
233
244
  specification_version: 4
234
245
  summary: An extension for asciidoctor that adds support for UML diagram generation
@@ -240,6 +251,7 @@ test_files:
240
251
  - spec/bpmn_spec.rb
241
252
  - spec/bytefield_spec.rb
242
253
  - spec/ditaa_spec.rb
254
+ - spec/dpic_spec.rb
243
255
  - spec/erd_spec.rb
244
256
  - spec/gnuplot_spec.rb
245
257
  - spec/graphviz_spec.rb
@@ -249,10 +261,12 @@ test_files:
249
261
  - spec/mermaid_spec.rb
250
262
  - spec/msc_spec.rb
251
263
  - spec/nomnoml_spec.rb
264
+ - spec/pikchr_spec.rb
252
265
  - spec/plantuml_spec.rb
253
266
  - spec/shaape_spec.rb
254
267
  - spec/smcat_spec.rb
255
268
  - spec/svgbob_spec.rb
269
+ - spec/symbolator_spec.rb
256
270
  - spec/syntrax_spec.rb
257
271
  - spec/test_helper.rb
258
272
  - spec/tikz_spec.rb