asciidoctor-diagram 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b61be6550e54410780169ba1b9f96a6656547d8c410fb066e7e02653f0926b86
4
- data.tar.gz: d8925319d5183c846784ee1d4aa78d7caa622f6beef3f693d7d2ac4e473b0e57
3
+ metadata.gz: 50d63dc4a063cfe9e7d03d217a2c9067042846dc23a46e27a3556ae7e7bb978c
4
+ data.tar.gz: f485e1ae1e9e20fce49499f888516339b8d927385704630ffb755de5fd917bff
5
5
  SHA512:
6
- metadata.gz: '02039d9b5b7657f8bdeab77cf80aa1135f27c293ecf16912378c61add0fbd6e5de8355198f61880af54a79dee9c4fa1fea15fce8b57c09ee872c3dcdfcd8e27a'
7
- data.tar.gz: 8d85bac0ac098b5151fdf724cd72eade0d9c9f2b8bf0c6522178b13f3275797d6b777e1a2483c315b19f597557e05dea6e79e206dce58d895116f47950e7aaea
6
+ metadata.gz: dc96dcd60863d23914cdc3007919093b149b755b66f1dd8fac36915c3b5e5ad24b927bed61ff59403ee82701195f3fc3aa01090f7a07d7f72a7b48b90967db3f
7
+ data.tar.gz: dd9b97377452d1cb6c519e1a891c570bcd5237ee59464c8f198370c6ca3bc690c8ab0944b4bbccf393d21f40f7aa5fd660745370308a0515bd1d1fc95c47da5d
data/CHANGELOG.adoc CHANGED
@@ -1,5 +1,21 @@
1
1
  = Asciidoctor-diagram Changelog
2
2
 
3
+ == 3.1.0
4
+
5
+ Enhancements::
6
+
7
+ * Issue #492: Add support for oxdraw
8
+ * Issue #496: Add `cache-images` option to keep a copy of generated images in the cache directory
9
+ * Issue #498: Add support for GoAT (@jmooring)
10
+ * Issue #499: Provide more control over label size in `meme` images
11
+
12
+ Bugfixes::
13
+
14
+ * Issue #487: Resolve issue where the `java.class.path` system property was being set to an incorrect value when running in JRuby
15
+ * Resolve compatibility issues with PlantUML 1.2025.9
16
+ * Issue #494: Resolve compatibility issues with Structurizr 5.x
17
+
18
+
3
19
  == 3.0.1
4
20
 
5
21
  Bugfixes::
@@ -172,18 +172,26 @@ module Asciidoctor
172
172
  image_file = parent.normalize_system_path(image_name, image_output_dir(parent))
173
173
  metadata_file = parent.normalize_system_path("#{image_name}.cache", cache_dir(source, parent))
174
174
 
175
+ metadata = {}
176
+ cached_image_file = image_file
177
+
175
178
  use_cache = !source.global_opt('nocache')
179
+ if use_cache
180
+ if File.exist?(metadata_file)
181
+ metadata = File.open(metadata_file, 'r') { |f| JSON.load(f, nil, :symbolize_names => true, :create_additions => false) }
182
+ end
176
183
 
177
- if use_cache && File.exist?(metadata_file)
178
- metadata = File.open(metadata_file, 'r') {|f| JSON.load(f, nil, :symbolize_names => true, :create_additions => false) }
179
- else
180
- metadata = {}
184
+ if source.global_opt('cache-images')
185
+ cached_image_file = parent.normalize_system_path("#{image_name}", cache_dir(source, parent))
186
+ end
181
187
  end
182
188
 
183
189
  image_attributes = source.attributes
184
190
  options = converter.collect_options(source)
185
191
 
186
- if !File.exist?(image_file) || source.should_process?(image_file, metadata) || options != metadata[:options]
192
+ regenerate_image = !File.exist?(cached_image_file) || source.should_process?(cached_image_file, metadata) || options != metadata[:options]
193
+
194
+ if regenerate_image
187
195
  params = IMAGE_PARAMS[format]
188
196
 
189
197
  server_url = source.global_attr('server-url')
@@ -209,11 +217,11 @@ module Asciidoctor
209
217
  allow_image_optimisation = !source.global_opt('nooptimise')
210
218
  image, metadata[:width], metadata[:height] = params[:decoder].post_process_image(image, allow_image_optimisation)
211
219
 
212
- FileUtils.mkdir_p(File.dirname(image_file)) unless Dir.exist?(File.dirname(image_file))
213
- File.open(image_file, 'wb') {|f| f.write image}
220
+ FileUtils.mkdir_p(File.dirname(cached_image_file)) unless Dir.exist?(File.dirname(cached_image_file))
221
+ File.open(cached_image_file, 'wb') {|f| f.write image}
214
222
 
215
223
  extra.each do |name, data|
216
- File.open(image_file + ".#{name}", 'wb') {|f| f.write data}
224
+ File.open(cached_image_file + ".#{name}", 'wb') {|f| f.write data}
217
225
  end
218
226
 
219
227
  if use_cache
@@ -224,6 +232,21 @@ module Asciidoctor
224
232
  end
225
233
  end
226
234
 
235
+ if cached_image_file != image_file && (!File.exist?(image_file) || regenerate_image)
236
+ FileUtils.mkdir_p(File.dirname(image_file)) unless Dir.exist?(File.dirname(image_file))
237
+
238
+ if Platform.os != :windows
239
+ begin
240
+ FileUtils.rm_f(image_file) if File.exist?(image_file)
241
+ File.link(cached_image_file, image_file)
242
+ rescue Errno::EXDEV
243
+ FileUtils.cp(cached_image_file, image_file, preserve: true)
244
+ end
245
+ else
246
+ FileUtils.cp(cached_image_file, image_file, preserve: true)
247
+ end
248
+ end
249
+
227
250
  scale = image_attributes['scale']
228
251
  if !converter.native_scaling? && scalematch = /([0-9]+(?:\.[0-9]+)?)/.match(scale)
229
252
  scale_factor = scalematch[1].to_f
@@ -0,0 +1,37 @@
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 GoATConverter
9
+ include DiagramConverter
10
+ include CliGenerator
11
+
12
+ def supported_formats
13
+ [:svg]
14
+ end
15
+
16
+ def collect_options(source)
17
+ {
18
+ sds: source.attr("svg-color-dark-scheme"),
19
+ sls: source.attr("svg-color-light-scheme"),
20
+ }
21
+ end
22
+
23
+ def convert(source, format, options)
24
+ sds, sls = options.values_at(:sds, :sls)
25
+ generate_stdin_stdout(source.find_command("goat"), source.code) do |tool|
26
+ args = [tool]
27
+ args.push("-sds", sds) if sds
28
+ args.push("-sls", sls) if sls
29
+ {
30
+ args: args,
31
+ chdir: source.base_dir,
32
+ }
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,18 @@
1
+ require_relative "converter"
2
+ require_relative "../diagram_processor"
3
+
4
+ module Asciidoctor
5
+ module Diagram
6
+ class GoATBlockProcessor < DiagramBlockProcessor
7
+ use_converter GoATConverter
8
+ end
9
+
10
+ class GoATBlockMacroProcessor < DiagramBlockMacroProcessor
11
+ use_converter GoATConverter
12
+ end
13
+
14
+ class GoATInlineMacroProcessor < DiagramInlineMacroProcessor
15
+ use_converter GoATConverter
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ require "asciidoctor/extensions"
2
+ require_relative "goat/extension"
3
+
4
+ Asciidoctor::Extensions.register do
5
+ block Asciidoctor::Diagram::GoATBlockProcessor, :goat
6
+ block_macro Asciidoctor::Diagram::GoATBlockMacroProcessor, :goat
7
+ inline_macro Asciidoctor::Diagram::GoATInlineMacroProcessor, :goat
8
+ end
@@ -19,27 +19,7 @@ module Asciidoctor
19
19
  bg_img = source.attr('background')
20
20
  raise "background attribute is required" unless bg_img
21
21
 
22
- margin = source.attr('margin', '')
23
- margin_parts = margin.split(' ')
24
- case margin_parts.length
25
- when 0
26
- ml = mr = mt = mb = nil
27
- when 1
28
- ml = mr = mt = mb = margin_parts[0]
29
- when 2
30
- mt = mb = margin_parts[0]
31
- ml = mr = margin_parts[1]
32
- when 3
33
- mt = margin_parts[0]
34
- ml = mr = margin_parts[1]
35
- mb = margin_parts[2]
36
- else
37
- mt = margin_parts[0]
38
- mr = margin_parts[1]
39
- mb = margin_parts[2]
40
- ml = margin_parts[3]
41
- end
42
-
22
+ height = source.attr('height-fraction', '20%')
43
23
  {
44
24
  :bg_img => bg_img,
45
25
  :top_label => source.attr('top'),
@@ -48,12 +28,9 @@ module Asciidoctor
48
28
  :stroke_color => source.attr(['strokecolor', 'stroke-color']),
49
29
  :stroke_width => source.attr(['strokewidth', 'stroke-width']),
50
30
  :font => source.attr('font', 'Impact'),
51
- :font_size => source.attr('font_size', nil),
52
- :alignment => source.attr('alignment', nil),
53
- :margin_left => ml,
54
- :margin_right => mr,
55
- :margin_top => mt,
56
- :margin_bottom => mb,
31
+ :height => height,
32
+ :top_height => source.attr('top-height', height),
33
+ :bottom_height => source.attr('bottom-height', height),
57
34
  :noupcase => source.opt('noupcase'),
58
35
  :imagesdir => source.attr('imagesdir')
59
36
  }
@@ -88,7 +65,8 @@ module Asciidoctor
88
65
  bg_width = dimensions['w'].to_i
89
66
  bg_height = dimensions['h'].to_i
90
67
  label_width = bg_width
91
- label_height = bg_height / 5
68
+ top_label_height = calculate_height(bg_height, options[:top_height])
69
+ bottom_label_height = calculate_height(bg_height, options[:bottom_height])
92
70
 
93
71
  if top_label
94
72
  top_img = Tempfile.new(['meme', '.png'])
@@ -98,7 +76,7 @@ module Asciidoctor
98
76
  '-stroke', stroke_color,
99
77
  '-strokewidth', stroke_width,
100
78
  '-font', font,
101
- '-size', "#{label_width}x#{label_height}",
79
+ '-size', "#{label_width}x#{top_label_height}",
102
80
  '-gravity', 'north',
103
81
  "label:#{prepare_label(top_label, noupcase)}",
104
82
  top_img.path
@@ -115,7 +93,7 @@ module Asciidoctor
115
93
  '-stroke', stroke_color,
116
94
  '-strokewidth', stroke_width,
117
95
  '-font', font,
118
- '-size', "#{label_width}x#{label_height}",
96
+ '-size', "#{label_width}x#{bottom_label_height}",
119
97
  '-gravity', 'south',
120
98
  "label:#{prepare_label(bottom_label, noupcase)}",
121
99
  bottom_img.path
@@ -132,7 +110,7 @@ module Asciidoctor
132
110
  end
133
111
 
134
112
  if bottom_img
135
- args << bottom_img.path << '-geometry' << "+0+#{bg_height - label_height}" << '-composite'
113
+ args << bottom_img.path << '-geometry' << "+0+#{bg_height - bottom_label_height}" << '-composite'
136
114
  end
137
115
 
138
116
  args << final_img.path
@@ -149,6 +127,16 @@ module Asciidoctor
149
127
  label = label.gsub(' // ', '\n')
150
128
  label
151
129
  end
130
+
131
+ def calculate_height(total_height, fraction_or_absolute_height)
132
+ if fraction_or_absolute_height.match(/^(\d+)%$/)
133
+ total_height * $1.to_i / 100
134
+ elsif fraction_or_absolute_height.match(/^(\d+)(px)?$/)
135
+ $1.to_i
136
+ else
137
+ raise "Invalid height value '#{fraction_or_absolute_height}'"
138
+ end
139
+ end
152
140
  end
153
141
  end
154
142
  end
@@ -0,0 +1,64 @@
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 OxdrawConverter
9
+ include DiagramConverter
10
+ include CliGenerator
11
+
12
+ def supported_formats
13
+ [:svg, :png]
14
+ end
15
+
16
+ def native_scaling?
17
+ true
18
+ end
19
+
20
+ def collect_options(source)
21
+ {
22
+ :background => source.attr('background'),
23
+ :scale => source.attr('scale')
24
+ }
25
+ end
26
+
27
+ def convert(source, format, options)
28
+ data = generate_stdin(source.find_command('oxdraw'), format.to_s, source.code) do |tool_path, output_path|
29
+ args = [tool_path]
30
+
31
+ options.each_pair do |key, value|
32
+ unless value.nil?
33
+ args << "--#{key.to_s.gsub('_', '-')}"
34
+ args << value
35
+ end
36
+ end
37
+
38
+ args << '--input'
39
+ args << '-'
40
+ args << '--output'
41
+ args << Platform.native_path(output_path)
42
+ args << '--output-format'
43
+ args << format.to_s
44
+ args << '--quiet'
45
+
46
+ {
47
+ :args => args,
48
+ :chdir => source.base_dir
49
+ }
50
+ end
51
+
52
+ # oxdraw doesn't perform scaling for SVG files, so we have to do it ourselves since we claim to support native
53
+ # scaling
54
+ if format == :svg && options[:scale]
55
+ scale = options[:scale].to_f
56
+ data.sub!(/(<svg.*width=")([0-9]+)(".*>)/) { |_| $1 + ($2.to_i * scale).to_i.to_s + $3 }
57
+ data.sub!(/(<svg.*height=")([0-9]+)(".*>)/) { |_| $1 + ($2.to_i * scale).to_i.to_s + $3 }
58
+ end
59
+
60
+ data
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,18 @@
1
+ require_relative 'converter'
2
+ require_relative '../diagram_processor'
3
+
4
+ module Asciidoctor
5
+ module Diagram
6
+ class OxdrawBlockProcessor < DiagramBlockProcessor
7
+ use_converter OxdrawConverter
8
+ end
9
+
10
+ class OxdrawBlockMacroProcessor < DiagramBlockMacroProcessor
11
+ use_converter OxdrawConverter
12
+ end
13
+
14
+ class OxdrawInlineMacroProcessor < DiagramInlineMacroProcessor
15
+ use_converter OxdrawConverter
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ require 'asciidoctor/extensions'
2
+ require_relative 'oxdraw/extension'
3
+
4
+ Asciidoctor::Extensions.register do
5
+ block Asciidoctor::Diagram::OxdrawBlockProcessor, :oxdraw
6
+ block_macro Asciidoctor::Diagram::OxdrawBlockMacroProcessor, :oxdraw
7
+ inline_macro Asciidoctor::Diagram::OxdrawInlineMacroProcessor, :oxdraw
8
+ end
@@ -50,7 +50,7 @@ module Asciidoctor
50
50
  }
51
51
  headers['X-Structurizr-View'] = options[:view] if options[:view]
52
52
  headers['X-Structurizr-IncludeDir'] = Platform.native_path(source.base_dir)
53
-
53
+ headers['X-Structurizr-Secure'] = 'false'
54
54
 
55
55
  response = Java.send_request(
56
56
  :url => '/structurizr',
@@ -25,7 +25,7 @@ module Asciidoctor
25
25
  java_cp = ::Java.java.lang.System.getProperty("java.class.path")
26
26
  new_java_cp = java_cp.split(File::PATH_SEPARATOR)
27
27
  .reject { |p| p.empty? }
28
- .join "File::PATH_SEPARATOR"
28
+ .join(File::PATH_SEPARATOR)
29
29
  ::Java.java.lang.System.setProperty("java.class.path", new_java_cp)
30
30
 
31
31
  @loaded = true
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Diagram
3
- VERSION = "3.0.1"
3
+ VERSION = "3.1.0"
4
4
  end
5
5
  end
@@ -9,6 +9,7 @@ require_relative 'asciidoctor-diagram/diagrams'
9
9
  require_relative 'asciidoctor-diagram/ditaa'
10
10
  require_relative 'asciidoctor-diagram/dpic'
11
11
  require_relative 'asciidoctor-diagram/erd'
12
+ require_relative 'asciidoctor-diagram/goat'
12
13
  require_relative 'asciidoctor-diagram/gnuplot'
13
14
  require_relative 'asciidoctor-diagram/graphviz'
14
15
  require_relative 'asciidoctor-diagram/graphviz_py'
@@ -17,6 +18,7 @@ require_relative 'asciidoctor-diagram/meme'
17
18
  require_relative 'asciidoctor-diagram/mermaid'
18
19
  require_relative 'asciidoctor-diagram/msc'
19
20
  require_relative 'asciidoctor-diagram/nomnoml'
21
+ require_relative 'asciidoctor-diagram/oxdraw'
20
22
  require_relative 'asciidoctor-diagram/penrose'
21
23
  require_relative 'asciidoctor-diagram/pikchr'
22
24
  require_relative 'asciidoctor-diagram/pintora'
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-diagram
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pepijn Van Eeckhoudt
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 2025-06-19 00:00:00.000000000 Z
11
+ date: 2025-11-16 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: bundler
@@ -138,6 +139,9 @@ files:
138
139
  - lib/asciidoctor-diagram/gnuplot.rb
139
140
  - lib/asciidoctor-diagram/gnuplot/converter.rb
140
141
  - lib/asciidoctor-diagram/gnuplot/extension.rb
142
+ - lib/asciidoctor-diagram/goat.rb
143
+ - lib/asciidoctor-diagram/goat/converter.rb
144
+ - lib/asciidoctor-diagram/goat/extension.rb
141
145
  - lib/asciidoctor-diagram/graphviz.rb
142
146
  - lib/asciidoctor-diagram/graphviz/converter.rb
143
147
  - lib/asciidoctor-diagram/graphviz/extension.rb
@@ -161,6 +165,9 @@ files:
161
165
  - lib/asciidoctor-diagram/nomnoml.rb
162
166
  - lib/asciidoctor-diagram/nomnoml/converter.rb
163
167
  - lib/asciidoctor-diagram/nomnoml/extension.rb
168
+ - lib/asciidoctor-diagram/oxdraw.rb
169
+ - lib/asciidoctor-diagram/oxdraw/converter.rb
170
+ - lib/asciidoctor-diagram/oxdraw/extension.rb
164
171
  - lib/asciidoctor-diagram/penrose.rb
165
172
  - lib/asciidoctor-diagram/penrose/converter.rb
166
173
  - lib/asciidoctor-diagram/penrose/extension.rb
@@ -173,7 +180,7 @@ files:
173
180
  - lib/asciidoctor-diagram/plantuml.rb
174
181
  - lib/asciidoctor-diagram/plantuml/converter.rb
175
182
  - lib/asciidoctor-diagram/plantuml/extension.rb
176
- - lib/asciidoctor-diagram/plantuml/plantuml-2.2.5.jar
183
+ - lib/asciidoctor-diagram/plantuml/plantuml-2.2.6.jar
177
184
  - lib/asciidoctor-diagram/salt.rb
178
185
  - lib/asciidoctor-diagram/shaape.rb
179
186
  - lib/asciidoctor-diagram/shaape/converter.rb
@@ -185,7 +192,7 @@ files:
185
192
  - lib/asciidoctor-diagram/structurizr/converter.rb
186
193
  - lib/asciidoctor-diagram/structurizr/extension.rb
187
194
  - lib/asciidoctor-diagram/structurizr/renderers.rb
188
- - lib/asciidoctor-diagram/structurizr/structurizr-2.2.2.jar
195
+ - lib/asciidoctor-diagram/structurizr/structurizr-2.2.9.jar
189
196
  - lib/asciidoctor-diagram/svgbob.rb
190
197
  - lib/asciidoctor-diagram/svgbob/converter.rb
191
198
  - lib/asciidoctor-diagram/svgbob/extension.rb
@@ -232,6 +239,7 @@ metadata:
232
239
  documentation_uri: https://docs.asciidoctor.org/diagram-extension/latest/
233
240
  homepage_uri: https://github.com/asciidoctor/asciidoctor-diagram
234
241
  source_code_uri: https://github.com/asciidoctor/asciidoctor-diagram.git
242
+ post_install_message:
235
243
  rdoc_options: []
236
244
  require_paths:
237
245
  - lib
@@ -246,7 +254,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
254
  - !ruby/object:Gem::Version
247
255
  version: '0'
248
256
  requirements: []
249
- rubygems_version: 3.6.3
257
+ rubygems_version: 3.5.16
258
+ signing_key:
250
259
  specification_version: 4
251
260
  summary: A family of Asciidoctor extensions that generate images from a broad range
252
261
  of embedded plain text diagram descriptions, including PlantUML, ditaa, Kroki, and