asciidoctor-diagram 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d37e7e92d9ff0bcae6607a862a17d8d642a54ad482f896a671c698993c22ad18
4
- data.tar.gz: 9da43fb78ccd16a79e341c662f0e6dae0fdb2edf4bd9697005f4321c8e518fe0
3
+ metadata.gz: 2c23479ec496e71fd006564fec4e1ca6cf88bd09ae730437e39e3d2dab6554c8
4
+ data.tar.gz: 583614138465d13c09a0134a888ecb513b27e9040d1d946fd62038c1421cfaf3
5
5
  SHA512:
6
- metadata.gz: 5366ef0c9961283fa4df0dd1b59774237dfc78923160e705d739d856f7b8dd64dc0edd4b93bc7cc139e413481dd597a384b952e52483a36a672e3f47eed30e2f
7
- data.tar.gz: b2828d5e8987b2f27f2c1c55a0bd80eae39b7c2015c09c9899cf5ad1ce0e264cef2af7782a402225ceea81027f65ef12480a8882af90e0dd4571e98fb1571c5c
6
+ metadata.gz: 92fdb3bcfbf238bbcfc13f2ea84b5441c9db60c98e053bef529487351c82fb07192d44304661fd1ede94fa3286923029bb3e93f72c5bb5ffd3a8f8cbeda2227e
7
+ data.tar.gz: bc7a9000e2ae1beeed9e61d538938241b6401a5aa4cff8bb5b9d15f8fe8dd7c4991b58ea326677feaf9f6e72f20c72961ce1286c53ed0704e5d48af102ad99e7
@@ -1,5 +1,11 @@
1
1
  = Asciidoctor-diagram Changelog
2
2
 
3
+ == 2.0.1
4
+
5
+ Bug Fixes::
6
+
7
+ * Issue #254: On Windows generating PlantUML or Ditaa diagrams would cause asciidoctor-diagram to block indefinitely
8
+
3
9
  == 2.0.0
4
10
 
5
11
  Enhancements::
@@ -347,7 +347,7 @@ Occurrences of `//` surrounded by whitespace are interpreted as line breaks.
347
347
  === Diagram Attributes
348
348
 
349
349
  Certain diagram types allow image generation to be customized using attributes.
350
- Each attribute can be specified either at the block level or at the document level.
350
+ Each attribute can be specified per individual diagram block or for all blocks of a given diagram type in a document level.
351
351
  This is illustrated for the blockdiag `fontpath` attribute in the example below.
352
352
 
353
353
  ----
@@ -362,13 +362,23 @@ This is illustrated for the blockdiag `fontpath` attribute in the example below.
362
362
  ....
363
363
  ....
364
364
  ----
365
- <1> Block level attributes can be specified at the document level by prefixing them with `<blocktype>-`
366
- <2> The first diagram does not specify an explicit value for `fontpath` so the global value will be used
367
- <3> The second diagram specifies a `fontpath` value which overrrides the global value
365
+ <1> Attributes can be specified for all diagram of a certain type at the document level by prefixing them with `<blocktype>-`.
366
+ In this example, the `fontpath` attribute is specified for all diagrams of type `blockdiag`.
367
+ <2> The first diagram does not specify an explicit value for `fontpath` so the global `blockdiag-fontpath` value will be used
368
+ <3> The second diagram does specifie a `fontpath` value.
369
+ This overrides the global `blockdiag-fontpath` value.
368
370
 
369
371
  Each attribute can either be specified at the block level or at the document level.
370
372
  The attribute name at the block level should be prefixed with the name of the diagram type and a dash.
371
373
 
374
+ ==== Shared Attributes
375
+
376
+ [cols=">,<,<",options="header"]
377
+ |===
378
+ |Name |Default value |Description
379
+ |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.
380
+ |===
381
+
372
382
  ==== AsciiToSVG
373
383
 
374
384
  [cols=">,<,<",options="header"]
@@ -439,9 +449,9 @@ The attribute name at the block level should be prefixed with the name of the di
439
449
  [cols=">,<,<",options="header"]
440
450
  |===
441
451
  |Name |Default value |Description
442
- |fillColor |white |The fill color for the text.
443
- |strokeColor |black |The outline color for the text
444
- |strokeWidth |2 |The width of the text outline.
452
+ |fill-color |white |The fill color for the text.
453
+ |stroke-color |black |The outline color for the text
454
+ |stroke-width |2 |The width of the text outline.
445
455
  |font |Impact |The font face to use for the text.
446
456
  |options |unspecified |a comma separate list of flags that modify the image rendering. Currently only `noupcase` is supported which disable upper casing the labels.
447
457
  |===
@@ -454,9 +464,9 @@ The attribute name at the block level should be prefixed with the name of the di
454
464
  |background |FFFFFF |The background colour of the image. The format should be a six-digit hexadecimal number (as in HTML, FF0000 for red). Pass an eight-digit hex to define transparency.
455
465
  |css |unspecified |Path to a CSS file to pass to mermaid.
456
466
  |config |unspecified |Path to a JSON config file to pass to mermaid.
457
- |ganttConfig |unspecified |Path to a gantt config file to pass to mermaid.
458
- |puppeteerConfig |unspecified |Path to a puppeteer config file to pass to mermaid.
459
- |sequenceConfig |unspecified |Path to a sequence config file to pass to mermaid.
467
+ |gantt-config |unspecified |Path to a gantt config file to pass to mermaid.
468
+ |puppeteer-config|unspecified |Path to a puppeteer config file to pass to mermaid.
469
+ |sequence-config |unspecified |Path to a sequence config file to pass to mermaid.
460
470
  |theme |unspecified |Theme of the chart, could be default, forest, dark or neutral.
461
471
  |width |unspecified |Width of the page.
462
472
  |height |unspecified |Height of the page.
@@ -4,6 +4,7 @@ require 'digest'
4
4
  require 'json'
5
5
  require 'fileutils'
6
6
  require_relative 'diagram_source.rb'
7
+ require_relative 'http/converter'
7
8
  require_relative 'version'
8
9
  require_relative 'util/java'
9
10
  require_relative 'util/gif'
@@ -29,6 +30,8 @@ module Asciidoctor
29
30
  host_class.extend(ClassMethods)
30
31
  end
31
32
 
33
+ DIAGRAM_PREFIX = 'diagram'
34
+
32
35
  IMAGE_PARAMS = {
33
36
  :svg => {
34
37
  :encoding => Encoding::UTF_8,
@@ -66,7 +69,7 @@ module Asciidoctor
66
69
  supported_formats = converter.supported_formats
67
70
 
68
71
  begin
69
- format = source.attributes.delete('format') || source.attr('format', supported_formats[0], name)
72
+ format = source.attributes.delete('format') || source.attr('format', nil, name) || source.attr('format', supported_formats[0], DIAGRAM_PREFIX)
70
73
  format = format.to_sym if format.respond_to?(:to_sym)
71
74
 
72
75
  raise "Format undefined" unless format
@@ -78,8 +81,8 @@ module Asciidoctor
78
81
  caption = source.attributes.delete 'caption'
79
82
 
80
83
  case format
81
- when :txt
82
- block = create_literal_block(parent, source, converter)
84
+ when :txt, :atxt, :utxt
85
+ block = create_literal_block(parent, source, format, converter)
83
86
  else
84
87
  block = create_image_block(parent, source, format, converter)
85
88
  end
@@ -88,7 +91,7 @@ module Asciidoctor
88
91
  block.assign_caption(caption, 'figure')
89
92
  block
90
93
  rescue => e
91
- case source.attr('on-error', 'log', 'diagram')
94
+ case source.attr('on-error', 'log', DIAGRAM_PREFIX)
92
95
  when 'abort'
93
96
  raise e
94
97
  else
@@ -158,6 +161,12 @@ module Asciidoctor
158
161
  if !File.exist?(image_file) || source.should_process?(image_file, metadata)
159
162
  params = IMAGE_PARAMS[format]
160
163
 
164
+ server_url = source.attr('server-url', nil, name) || source.attr('server-url', nil, DIAGRAM_PREFIX)
165
+ if server_url
166
+ server_type = source.attr('server-type', nil, name) || source.attr('server-type', 'plantuml', DIAGRAM_PREFIX)
167
+ converter = HttpConverter.new(server_url, server_type.to_sym, converter)
168
+ end
169
+
161
170
  options = converter.collect_options(source, name)
162
171
  result = converter.convert(source, format, options)
163
172
 
@@ -175,7 +184,7 @@ module Asciidoctor
175
184
 
176
185
  image_attributes['target'] = source.attr('data-uri', nil, true) ? image_file : image_name
177
186
  if format == :svg
178
- svg_type = source.attr('svg-type', nil, 'diagram')
187
+ svg_type = source.attr('svg-type', nil, name) || source.attr('svg-type', nil, DIAGRAM_PREFIX)
179
188
  image_attributes['opts'] = svg_type if svg_type && svg_type != 'static'
180
189
  end
181
190
 
@@ -249,12 +258,12 @@ module Asciidoctor
249
258
  parent.normalize_system_path(cache_dir, base_dir)
250
259
  end
251
260
 
252
- def create_literal_block(parent, source, converter)
261
+ def create_literal_block(parent, source, format, converter)
253
262
  literal_attributes = source.attributes
254
263
  literal_attributes.delete('target')
255
264
 
256
265
  options = converter.collect_options(source, name)
257
- result = converter.convert(source, :txt, options)
266
+ result = converter.convert(source, format, options)
258
267
 
259
268
  result.force_encoding(Encoding::UTF_8)
260
269
  Asciidoctor::Block.new parent, :literal, :source => result, :attributes => literal_attributes
@@ -0,0 +1,79 @@
1
+ require_relative '../diagram_converter'
2
+ require_relative '../util/cli_generator'
3
+ require_relative '../util/platform'
4
+
5
+ require 'base64'
6
+ require 'net/http'
7
+ require 'uri'
8
+ require 'zlib'
9
+
10
+ module Asciidoctor
11
+ module Diagram
12
+ # @private
13
+ class HttpConverter
14
+ include DiagramConverter
15
+
16
+ def initialize(base_uri, type, converter)
17
+ @base_uri = base_uri
18
+ @type = type
19
+ @converter = converter
20
+ end
21
+
22
+ def supported_formats
23
+ @converter.supported_formats
24
+ end
25
+
26
+ def collect_options(source, name)
27
+ {
28
+ :block_name => name
29
+ }
30
+ end
31
+
32
+ def convert(source, format, options)
33
+ code = source.code
34
+
35
+ uri = URI(@base_uri)
36
+
37
+ case @type
38
+ when :plantuml
39
+ deflate = Zlib::Deflate.new(Zlib::BEST_COMPRESSION,
40
+ -Zlib::MAX_WBITS,
41
+ Zlib::MAX_MEM_LEVEL,
42
+ Zlib::DEFAULT_STRATEGY)
43
+
44
+ compressed = deflate.deflate(code, Zlib::FINISH)
45
+ deflate.close
46
+
47
+ encoded = Base64.urlsafe_encode64(compressed)
48
+ data = '0A' + encoded
49
+
50
+ path = uri.path
51
+ path << '/' unless path.end_with? '/'
52
+ path << format.to_s
53
+ path << '/' << data
54
+ when :kroki_io
55
+ compressed = Zlib.deflate(code, Zlib::BEST_COMPRESSION)
56
+ data = Base64.urlsafe_encode64(compressed)
57
+
58
+ path = uri.path
59
+ path << '/' unless path.end_with? '/'
60
+ path << options[:block_name].to_s
61
+ path << '/' << format.to_s
62
+ path << '/' << data
63
+ else
64
+ raise "Unsupported server type: " + @type
65
+ end
66
+
67
+ Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme.downcase == 'https') do |http|
68
+ response = http.request_get path
69
+ case response
70
+ when Net::HTTPSuccess
71
+ response.body
72
+ else
73
+ response.value
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -18,7 +18,7 @@ module Asciidoctor
18
18
  Java.classpath.concat JARS
19
19
 
20
20
  def supported_formats
21
- [:png, :svg, :txt]
21
+ [:png, :svg, :txt, :atxt, :utxt]
22
22
  end
23
23
 
24
24
  def collect_options(source, name)
@@ -37,8 +37,10 @@ module Asciidoctor
37
37
  mime_type = 'image/png'
38
38
  when :svg
39
39
  mime_type = 'image/svg+xml'
40
- when :txt
40
+ when :txt, :utxt
41
41
  mime_type = 'text/plain;charset=utf-8'
42
+ when :atxt
43
+ mime_type = 'text/plain;charset=us-ascii'
42
44
  else
43
45
  raise "Unsupported format: #{format}"
44
46
  end
@@ -17,7 +17,7 @@ module Asciidoctor
17
17
  args << classpath.flatten.map { |jar| ::Asciidoctor::Diagram::Platform.host_os_path(jar).strip }.join(::Asciidoctor::Diagram::Platform.host_os_path_separator)
18
18
  args << 'org.asciidoctor.diagram.StdInOutCommandServer'
19
19
 
20
- @server = IO.popen([java, *args], 'r+')
20
+ @server = IO.popen([java, *args], 'r+b')
21
21
  end
22
22
 
23
23
  def io
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Diagram
3
- VERSION = "2.0.0"
3
+ VERSION = "2.0.1"
4
4
  end
5
5
  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.0.0
4
+ version: 2.0.1
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: 2019-12-15 00:00:00.000000000 Z
11
+ date: 2020-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -115,6 +115,7 @@ files:
115
115
  - lib/asciidoctor-diagram/graphviz.rb
116
116
  - lib/asciidoctor-diagram/graphviz/converter.rb
117
117
  - lib/asciidoctor-diagram/graphviz/extension.rb
118
+ - lib/asciidoctor-diagram/http/converter.rb
118
119
  - lib/asciidoctor-diagram/http/server.rb
119
120
  - lib/asciidoctor-diagram/lilypond.rb
120
121
  - lib/asciidoctor-diagram/lilypond/converter.rb
@@ -222,7 +223,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
223
  - !ruby/object:Gem::Version
223
224
  version: '0'
224
225
  requirements: []
225
- rubygems_version: 3.0.3
226
+ rubyforge_project:
227
+ rubygems_version: 2.7.6
226
228
  signing_key:
227
229
  specification_version: 4
228
230
  summary: An extension for asciidoctor that adds support for UML diagram generation