asciidoctor-diagram 2.2.14 → 2.2.15

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.

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: c2447be8f4a47717d6ef4856ed210cbf44eaa09cd0ae154bb64119f3e309384d
4
- data.tar.gz: 8e40700cddd6d026c7ae4cd7cfafdf22704e01b4941eba2d274db91e103d700e
3
+ metadata.gz: abbe19abb01debdac1a825fc45f134179aea8b777976bb3bf73d17c450d1e314
4
+ data.tar.gz: 3e542e7db49e7dbfaebc77c7d69d88394c9856c3c24c910b49ee9282d5c4fbc6
5
5
  SHA512:
6
- metadata.gz: 2e4c640aaa5ce31f00f94a10398d9ab9a29eca0a97359073645a82cd777ec860ad2a90ebc5ed549e65186a88d3e1c43a9f39250c1d2b6ba2745f31d4b3dd3679
7
- data.tar.gz: 9f54def1db4fd022b510a46daf33328b4854fb0d1dd7d3ba4bbc5a5dc1c966e4a37f548fdaa82c626024fdb31bdbf62218e1edbb1e8bdf1a7bf43fbf10116567
6
+ metadata.gz: d8fcda204a78487af2ee295eb63a0bc0bdf6f92a140fad4b424c9ee2a78032316fc1fae5779d689430c1d77d427c059df718c75239f29504e1f78950bac9d941
7
+ data.tar.gz: d65c13fca70b74b91133154103c6012f9d8f944d900a06842553b5dcdb89e9095c1a01bc475ce7e55082f7987313ad84037971c66867afd40829a2bc8595f3df
data/CHANGELOG.adoc CHANGED
@@ -1,5 +1,16 @@
1
1
  = Asciidoctor-diagram Changelog
2
2
 
3
+ == 2.2.15
4
+
5
+ Enhacements::
6
+
7
+ * Issue #453: Improve error message when WaveDrom cannot be located
8
+
9
+ Bugfixes::
10
+
11
+ * Issue #428: Improve support for reading UTF-16 encoded source files
12
+ * Issue #449: Fix resolving of relative `!include` paths in Structurizr DSL input.
13
+
3
14
  == 2.2.14
4
15
 
5
16
  Bugfixes::
data/README.adoc CHANGED
@@ -23,16 +23,16 @@ The example below shows an embedded Ditaa diagram block.
23
23
  ---------
24
24
  [ditaa]
25
25
  ----
26
- +-------------+
27
- | asciidoctor |-----------+
28
- | diagram | |
29
- +-------------+ | image
30
- ^ |
31
- | diagram source |
32
- | v
33
- +--------+ +-----+-------+ /---------------\
34
- | adoc |-->+ asciidoctor + | HTML + image |
35
- +--------+ +-------------+ \---------------/
26
+ +-------------+
27
+ | asciidoctor |---------------+
28
+ | diagram | |
29
+ +-------------+ | image
30
+ ^ |
31
+ | diagram source |
32
+ | v
33
+ +--------+ +------+------+ /--------------\
34
+ | adoc |------>+ asciidoctor +------->| HTML + image |
35
+ +--------+ +-------------+ html \--------------/
36
36
  ----
37
37
  ---------
38
38
 
@@ -305,8 +305,7 @@ module Asciidoctor
305
305
 
306
306
  def load_code
307
307
  if @file_name
308
- lines = File.readlines(@file_name)
309
- lines = prepare_source_array(lines)
308
+ lines = prepare_source_array(File.read(@file_name, :mode => 'rb'))
310
309
  @parent_block.apply_subs(lines, resolve_diagram_subs).join("\n")
311
310
  else
312
311
  ''
@@ -315,39 +314,33 @@ module Asciidoctor
315
314
 
316
315
  private
317
316
 
318
- # Byte arrays for UTF-* Byte Order Marks
319
- BOM_BYTES_UTF_8 = [0xef, 0xbb, 0xbf]
320
- BOM_BYTES_UTF_16LE = [0xff, 0xfe]
321
- BOM_BYTES_UTF_16BE = [0xfe, 0xff]
317
+ # Raw binary strings for UTF-* Byte Order Marks
318
+ BOM_BYTES_UTF_8 = String.new("\xef\xbb\xbf", :encoding => Encoding::ASCII_8BIT)
319
+ BOM_BYTES_UTF_16LE = String.new("\xff\xfe", :encoding => Encoding::ASCII_8BIT)
320
+ BOM_BYTES_UTF_16BE = String.new("\xfe\xff", :encoding => Encoding::ASCII_8BIT)
322
321
 
323
- # Prepare the source data Array for parsing.
322
+ # Prepare the source data for parsing.
324
323
  #
325
- # Encodes the data to UTF-8, if necessary, and removes any trailing
324
+ # Encodes the data to UTF-8 and removes any trailing
326
325
  # whitespace from every line.
327
326
  #
328
- # If a BOM is found at the beginning of the data, a best attempt is made to
329
- # encode it to UTF-8 from the specified source encoding.
330
- #
331
- # data - the source data Array to prepare (no nil entries allowed)
327
+ # data - the source data to prepare
332
328
  #
333
329
  # returns a String Array of prepared lines
334
330
  def prepare_source_array data
335
331
  return [] if data.empty?
336
- if (leading_2_bytes = (leading_bytes = (first = data[0]).unpack 'C3').slice 0, 2) == BOM_BYTES_UTF_16LE
337
- data[0] = first.byteslice 2, first.bytesize
338
- # NOTE you can't split a UTF-16LE string using .lines when encoding is UTF-8; doing so will cause this line to fail
339
- return data.map {|line| (line.encode ::Encoding::UTF_8, ::Encoding::UTF_16LE).rstrip}
340
- elsif leading_2_bytes == BOM_BYTES_UTF_16BE
341
- data[0] = first.byteslice 2, first.bytesize
342
- return data.map {|line| (line.encode ::Encoding::UTF_8, ::Encoding::UTF_16BE).rstrip}
343
- elsif leading_bytes == BOM_BYTES_UTF_8
344
- data[0] = first.byteslice 3, first.bytesize
345
- end
346
- if first.encoding == ::Encoding::UTF_8
347
- data.map {|line| line.rstrip}
332
+
333
+ if data.start_with?(BOM_BYTES_UTF_16LE)
334
+ utf8_data = data.byteslice(2, data.bytesize).encode(::Encoding::UTF_8, ::Encoding::UTF_16LE)
335
+ elsif data.start_with?(BOM_BYTES_UTF_16BE)
336
+ utf8_data = data.byteslice(2, data.bytesize).encode(::Encoding::UTF_8, ::Encoding::UTF_16BE)
337
+ elsif data.start_with?(BOM_BYTES_UTF_8)
338
+ utf8_data = data.byteslice(3, data.bytesize).encode(::Encoding::UTF_8)
348
339
  else
349
- data.map {|line| (line.encode ::Encoding::UTF_8).rstrip}
340
+ utf8_data = data.encode(::Encoding::UTF_8)
350
341
  end
342
+
343
+ utf8_data.lines.map {|line| line.rstrip}
351
344
  end
352
345
  end
353
346
  end
@@ -49,6 +49,8 @@ module Asciidoctor
49
49
  'Accept' => Renderers.mime_type(options[:renderer])
50
50
  }
51
51
  headers['X-Structurizr-View'] = options[:view] if options[:view]
52
+ headers['X-Structurizr-IncludeDir'] = Platform.native_path(source.base_dir)
53
+
52
54
 
53
55
  response = Java.send_request(
54
56
  :url => '/structurizr',
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Diagram
3
- VERSION = "2.2.14"
3
+ VERSION = "2.2.15"
4
4
  end
5
5
  end
@@ -9,48 +9,53 @@ module Asciidoctor
9
9
  include DiagramConverter
10
10
  include CliGenerator
11
11
 
12
-
13
12
  def supported_formats
14
13
  [:png, :svg]
15
14
  end
16
15
 
17
-
18
16
  def convert(source, format, options)
19
- wavedrom_cli = source.find_command('wavedrom-cli', :raise_on_error => false)
20
- if wavedrom_cli
21
- generate_file(wavedrom_cli, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
17
+ wavedrom = source.find_command('wavedrom-cli', :attrs => ['wavedrom'], :raise_on_error => false)
18
+
19
+ unless wavedrom
20
+ wavedrom = source.find_command('wavedrom', :raise_on_error => false)
21
+ end
22
+
23
+ unless wavedrom
24
+ if ::Asciidoctor::Diagram::Platform.os == :macosx
25
+ wavedrom = source.find_command('WaveDromEditor.app', :alt_cmds => ['wavedrom-editor.app'], :attrs => ['WaveDromEditorApp'], :path => ['/Applications'], :raise_on_error => false)
26
+ if wavedrom
27
+ wavedrom = File.join(wavedrom, 'Contents/MacOS/nwjs')
28
+ end
29
+ else
30
+ wavedrom = source.find_command('WaveDromEditor', :raise_on_error => false)
31
+ end
32
+ end
33
+
34
+ unless wavedrom
35
+ source.find_command('wavedrom-cli', :attrs => ['wavedrom'])
36
+ end
37
+
38
+ if wavedrom.end_with?('-cli')
39
+ generate_file(wavedrom, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
22
40
  {
23
41
  :args => [Platform.native_path(tool_path), '--input', Platform.native_path(input_path), "--#{format.to_s}", Platform.native_path(output_path)],
24
42
  :chdir => source.base_dir
25
43
  }
26
44
  end
45
+ elsif wavedrom.include?('WaveDromEditor')
46
+ generate_file(wavedrom, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
47
+ {
48
+ :args => [tool_path, 'source', Platform.native_path(input_path), format.to_s, Platform.native_path(output_path)],
49
+ :chdir => source.base_dir
50
+ }
51
+ end
27
52
  else
28
- wavedrom_cli = source.find_command('wavedrom', :raise_on_error => false)
29
- phantomjs = source.find_command('phantomjs', :alt_attrs => ['phantomjs_2'], :raise_on_error => false)
30
-
31
- if wavedrom_cli && !wavedrom_cli.include?('WaveDromEditor') && phantomjs
32
- generate_file(wavedrom_cli, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
33
- {
34
- :args => [phantomjs, Platform.native_path(tool_path), '-i', Platform.native_path(input_path), "-#{format.to_s[0]}", Platform.native_path(output_path)],
35
- :chdir => source.base_dir
36
- }
37
- end
38
- else
39
- if ::Asciidoctor::Diagram::Platform.os == :macosx
40
- wavedrom = source.find_command('WaveDromEditor.app', :alt_cmds => ['wavedrom-editor.app'], :attrs => ['WaveDromEditorApp'], :path => ['/Applications'])
41
- if wavedrom
42
- wavedrom = File.join(wavedrom, 'Contents/MacOS/nwjs')
43
- end
44
- else
45
- wavedrom = source.find_command('WaveDromEditor')
46
- end
47
-
48
- generate_file(wavedrom, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
49
- {
50
- :args => [tool_path, 'source', Platform.native_path(input_path), format.to_s, Platform.native_path(output_path)],
51
- :chdir => source.base_dir
52
- }
53
- end
53
+ phantomjs = source.find_command('phantomjs', :alt_attrs => ['phantomjs_2'])
54
+ generate_file(wavedrom, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
55
+ {
56
+ :args => [phantomjs, Platform.native_path(tool_path), '-i', Platform.native_path(input_path), "-#{format.to_s[0]}", Platform.native_path(output_path)],
57
+ :chdir => source.base_dir
58
+ }
54
59
  end
55
60
  end
56
61
  end
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.2.14
4
+ version: 2.2.15
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: 2023-09-20 00:00:00.000000000 Z
11
+ date: 2024-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -211,7 +211,7 @@ files:
211
211
  - lib/asciidoctor-diagram/structurizr/converter.rb
212
212
  - lib/asciidoctor-diagram/structurizr/extension.rb
213
213
  - lib/asciidoctor-diagram/structurizr/renderers.rb
214
- - lib/asciidoctor-diagram/structurizr/structurizr-2.0.3.jar
214
+ - lib/asciidoctor-diagram/structurizr/structurizr-2.0.5.jar
215
215
  - lib/asciidoctor-diagram/svgbob.rb
216
216
  - lib/asciidoctor-diagram/svgbob/converter.rb
217
217
  - lib/asciidoctor-diagram/svgbob/extension.rb
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
272
  - !ruby/object:Gem::Version
273
273
  version: '0'
274
274
  requirements: []
275
- rubygems_version: 3.2.22
275
+ rubygems_version: 3.4.13
276
276
  signing_key:
277
277
  specification_version: 4
278
278
  summary: A family of Asciidoctor extensions that generate images from a broad range