asciidoctor-diagram 2.3.1 → 3.0.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 +4 -4
- data/CHANGELOG.adoc +21 -0
- data/README.adoc +15 -11
- data/lib/asciidoctor-diagram/diagram_processor.rb +21 -4
- data/lib/asciidoctor-diagram/diagram_source.rb +1 -9
- data/lib/asciidoctor-diagram/gnuplot/converter.rb +1 -0
- data/lib/asciidoctor-diagram/http/converter.rb +7 -2
- data/lib/asciidoctor-diagram/pintora/converter.rb +60 -0
- data/lib/asciidoctor-diagram/pintora/extension.rb +18 -0
- data/lib/asciidoctor-diagram/pintora.rb +8 -0
- data/lib/asciidoctor-diagram/plantuml/converter.rb +208 -31
- data/lib/asciidoctor-diagram/plantuml/plantuml-2.2.4.jar +0 -0
- data/lib/asciidoctor-diagram/structurizr/structurizr-2.2.2.jar +0 -0
- data/lib/asciidoctor-diagram/util/cli.rb +1 -1
- data/lib/asciidoctor-diagram/util/java.rb +15 -7
- data/lib/asciidoctor-diagram/util/java_jruby.rb +10 -0
- data/lib/asciidoctor-diagram/util/{server-2.2.0.jar → server-2.2.3.jar} +0 -0
- data/lib/asciidoctor-diagram/version.rb +1 -1
- data/lib/asciidoctor-diagram.rb +1 -0
- metadata +9 -37
- data/lib/asciidoctor-diagram/plantuml/plantuml-2.2.1.jar +0 -0
- data/lib/asciidoctor-diagram/structurizr/structurizr-2.2.0.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 993b52833cbee514282ba62841b0dfafc69760770884a42ea24843b6e9b58224
|
4
|
+
data.tar.gz: 38d9215b0859313c6610ec6876b65e2fee4437b87bcc1f2a01465c39db8dedc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15477c98c7d90da97ce45106f2f6159b26eb60caeeb0e9d36a700959e15aba484449334ba31c4d74e1bb6806f3360d477e1c424242ad2c3657dd2135d4d9b89f
|
7
|
+
data.tar.gz: 18b93c67ac75d7916eab56073b92a49c6a22ec52be0bc48bc5431d967d2c2a7968d570146a2c53acbf773452453b67dc76c539b69e5e3c9ce9df2d857d9d9cff
|
data/CHANGELOG.adoc
CHANGED
@@ -1,5 +1,26 @@
|
|
1
1
|
= Asciidoctor-diagram Changelog
|
2
2
|
|
3
|
+
== 3.0.0
|
4
|
+
|
5
|
+
Breaking Changes::
|
6
|
+
|
7
|
+
* Asciidoctor Diagram no longer has a runtime dependency on the https://rubygems.org/gems/asciidoctor-diagram-ditaamini[asciidoctor-diagram-ditaamini] and https://rubygems.org/gems/asciidoctor-diagram-plantuml[asciidoctor-diagram-plantuml] gems.
|
8
|
+
These gems will now have to be installed and required explicitly if necessary.
|
9
|
+
|
10
|
+
Enhancements::
|
11
|
+
|
12
|
+
* Issue #478: Add support for PlantUML native image builds (@fliiiix)
|
13
|
+
|
14
|
+
== 2.3.2
|
15
|
+
|
16
|
+
Enhancements::
|
17
|
+
|
18
|
+
* Issue #465: Add support for https://pintorajs.vercel.app/[Pintora]
|
19
|
+
* Issue #476: Use PlantUML's Smetana layout engine by default if Graphviz cannot be located
|
20
|
+
* Issue #477: Improve support for using plantuml.com as PlantUML rendering server
|
21
|
+
* Add support for Structurizr JSON workspaces
|
22
|
+
* Prefer non-PDF formats when rendering with HTML backend
|
23
|
+
|
3
24
|
== 2.3.1
|
4
25
|
|
5
26
|
Enhancements::
|
data/README.adoc
CHANGED
@@ -23,19 +23,23 @@ The example below shows an embedded Ditaa diagram block.
|
|
23
23
|
---------
|
24
24
|
[ditaa]
|
25
25
|
----
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
34
|
-
|
35
|
-
|
26
|
+
+-------------+
|
27
|
+
| Diagram +----------------+
|
28
|
+
| Renderer | |
|
29
|
+
+-------------+ |
|
30
|
+
| Asciidoctor | |
|
31
|
+
| Diagram | |
|
32
|
+
+-------------+ | Image
|
33
|
+
^ |
|
34
|
+
| Diagram source |
|
35
|
+
+---------------+ | v
|
36
|
+
| Asciidoc | +------+------+ /-------+------\
|
37
|
+
| with embedded +------>+ Asciidoctor +------->| Beautiful |
|
38
|
+
| diagram {d}| +-------------+ HTML | Output |
|
39
|
+
+---------------+ \--------------/
|
36
40
|
----
|
37
41
|
---------
|
38
42
|
|
39
43
|
After processing by Asciidoctor, the output file will show a rendered version of the diagram instead of the diagram source code.
|
40
44
|
|
41
|
-
image::docs/modules/ROOT/images/asciidoctor-diagram-process.png[]
|
45
|
+
image::docs/modules/ROOT/images/asciidoctor-diagram-process.png[]
|
@@ -81,6 +81,13 @@ module Asciidoctor
|
|
81
81
|
begin
|
82
82
|
source = converter.wrap_source(source)
|
83
83
|
|
84
|
+
if /html/i =~ parent.document.attributes['backend']
|
85
|
+
# Move PDF to the back of the list for the HTML backend
|
86
|
+
if supported_formats.delete(:pdf)
|
87
|
+
supported_formats << :pdf
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
84
91
|
format = source.attributes.delete('format') || source.global_attr('format', supported_formats[0])
|
85
92
|
format = format.to_sym if format.respond_to?(:to_sym)
|
86
93
|
|
@@ -187,17 +194,27 @@ module Asciidoctor
|
|
187
194
|
|
188
195
|
options = converter.collect_options(source)
|
189
196
|
result = converter.convert(source, format, options)
|
190
|
-
|
191
|
-
|
197
|
+
if result.is_a? Hash
|
198
|
+
image = result[:result]
|
199
|
+
extra = result[:extra]
|
200
|
+
else
|
201
|
+
image = result
|
202
|
+
extra = {}
|
203
|
+
end
|
204
|
+
image.force_encoding(params[:encoding])
|
192
205
|
|
193
206
|
metadata = source.create_image_metadata
|
194
207
|
metadata[:options] = options
|
195
208
|
|
196
209
|
allow_image_optimisation = !source.global_opt('nooptimise')
|
197
|
-
|
210
|
+
image, metadata[:width], metadata[:height] = params[:decoder].post_process_image(image, allow_image_optimisation)
|
198
211
|
|
199
212
|
FileUtils.mkdir_p(File.dirname(image_file)) unless Dir.exist?(File.dirname(image_file))
|
200
|
-
File.open(image_file, 'wb') {|f| f.write
|
213
|
+
File.open(image_file, 'wb') {|f| f.write image}
|
214
|
+
|
215
|
+
extra.each do |name, data|
|
216
|
+
File.open(image_file + ".#{name}", 'wb') {|f| f.write data}
|
217
|
+
end
|
201
218
|
|
202
219
|
if use_cache
|
203
220
|
FileUtils.mkdir_p(File.dirname(metadata_file)) unless Dir.exist?(File.dirname(metadata_file))
|
@@ -202,14 +202,6 @@ module Asciidoctor
|
|
202
202
|
name = [name] unless name.is_a?(Enumerable)
|
203
203
|
|
204
204
|
value = name.lazy.map { |n| @attributes[n] }.reject { |v| v.nil? }.first
|
205
|
-
if value.nil?
|
206
|
-
attr_position = config[:positional_attrs] || 1
|
207
|
-
while value.nil? && !@attributes[attr_position].nil?
|
208
|
-
if @attributes[attr_position] == name
|
209
|
-
value = true
|
210
|
-
end
|
211
|
-
end
|
212
|
-
end
|
213
205
|
|
214
206
|
if value.nil? && inherit
|
215
207
|
inherited_values = name.lazy.map do |n|
|
@@ -345,4 +337,4 @@ module Asciidoctor
|
|
345
337
|
end
|
346
338
|
end
|
347
339
|
end
|
348
|
-
end
|
340
|
+
end
|
@@ -72,7 +72,8 @@ module Asciidoctor
|
|
72
72
|
|
73
73
|
get_path = path.dup << '/' << data
|
74
74
|
|
75
|
-
|
75
|
+
host = uri.host
|
76
|
+
if (host.nil? || !host.downcase.end_with?('plantuml.com')) && get_path.length > options[:max_get_size]
|
76
77
|
uri.path = path
|
77
78
|
get_uri(uri, code, 'text/plain; charset=utf-8')
|
78
79
|
else
|
@@ -110,7 +111,11 @@ module Asciidoctor
|
|
110
111
|
resolved_uri = new_uri
|
111
112
|
end
|
112
113
|
|
113
|
-
|
114
|
+
if response.code == '307'
|
115
|
+
get_uri(resolved_uri, post_data, post_content_type, attempt + 1)
|
116
|
+
else
|
117
|
+
get_uri(resolved_uri, nil, nil, attempt + 1)
|
118
|
+
end
|
114
119
|
else
|
115
120
|
response.value
|
116
121
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require_relative '../diagram_converter'
|
2
|
+
require_relative '../util/cli'
|
3
|
+
require_relative '../util/cli_generator'
|
4
|
+
require_relative '../util/platform'
|
5
|
+
|
6
|
+
module Asciidoctor
|
7
|
+
module Diagram
|
8
|
+
# @private
|
9
|
+
class PintoraConverter
|
10
|
+
include DiagramConverter
|
11
|
+
include CliGenerator
|
12
|
+
|
13
|
+
|
14
|
+
def supported_formats
|
15
|
+
[:png, :svg]
|
16
|
+
end
|
17
|
+
|
18
|
+
def collect_options(source)
|
19
|
+
options = {}
|
20
|
+
|
21
|
+
options[:width] = source.attr('width')
|
22
|
+
options[:theme] = source.attr('theme')
|
23
|
+
options[:background_color] = source.attr('background-color')
|
24
|
+
options[:pixel_ratio] = source.attr('pixel-ratio')
|
25
|
+
|
26
|
+
options
|
27
|
+
end
|
28
|
+
|
29
|
+
def convert(source, format, options)
|
30
|
+
pintora = source.find_command('pintora')
|
31
|
+
|
32
|
+
generate_file(pintora, 'pintora', format.to_s, source.to_s) do |tool_path, input_path, output_path|
|
33
|
+
args = [tool_path, 'render', '-i', Platform.native_path(input_path), '-o', Platform.native_path(output_path)]
|
34
|
+
|
35
|
+
|
36
|
+
if options[:width]
|
37
|
+
args << '-w' << options[:width]
|
38
|
+
end
|
39
|
+
|
40
|
+
if options[:theme]
|
41
|
+
args << '-t' << options[:theme]
|
42
|
+
end
|
43
|
+
|
44
|
+
if options[:pixel_ratio]
|
45
|
+
args << '-p' << options[:pixel_ratio]
|
46
|
+
end
|
47
|
+
|
48
|
+
if options[:background_color]
|
49
|
+
args << '-b' << options[:background_color]
|
50
|
+
end
|
51
|
+
|
52
|
+
{
|
53
|
+
:args => args,
|
54
|
+
:chdir => source.base_dir
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'converter'
|
2
|
+
require_relative '../diagram_processor'
|
3
|
+
|
4
|
+
module Asciidoctor
|
5
|
+
module Diagram
|
6
|
+
class PintoraBlockProcessor < DiagramBlockProcessor
|
7
|
+
use_converter PintoraConverter
|
8
|
+
end
|
9
|
+
|
10
|
+
class PintoraBlockMacroProcessor < DiagramBlockMacroProcessor
|
11
|
+
use_converter PintoraConverter
|
12
|
+
end
|
13
|
+
|
14
|
+
class PintoraInlineMacroProcessor < DiagramInlineMacroProcessor
|
15
|
+
use_converter PintoraConverter
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'asciidoctor/extensions'
|
2
|
+
require_relative 'pintora/extension'
|
3
|
+
|
4
|
+
Asciidoctor::Extensions.register do
|
5
|
+
block Asciidoctor::Diagram::PintoraBlockProcessor, :pintora
|
6
|
+
block_macro Asciidoctor::Diagram::PintoraBlockMacroProcessor, :pintora
|
7
|
+
inline_macro Asciidoctor::Diagram::PintoraInlineMacroProcessor, :pintora
|
8
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require_relative '../diagram_converter'
|
2
2
|
require_relative '../util/java'
|
3
|
+
require_relative '../util/cli'
|
4
|
+
require_relative '../util/cli_generator'
|
3
5
|
require 'delegate'
|
4
6
|
require 'uri'
|
5
7
|
|
@@ -8,6 +10,7 @@ module Asciidoctor
|
|
8
10
|
# @private
|
9
11
|
class PlantUmlConverter
|
10
12
|
include DiagramConverter
|
13
|
+
include CliGenerator
|
11
14
|
|
12
15
|
CLASSPATH_ENV = Java.environment_variable('DIAGRAM_PLANTUML_CLASSPATH')
|
13
16
|
LIB_DIR = File.expand_path('../..', File.dirname(__FILE__))
|
@@ -27,6 +30,15 @@ module Asciidoctor
|
|
27
30
|
Java.classpath.concat PLANTUML_JARS
|
28
31
|
end
|
29
32
|
|
33
|
+
def self.find_plantuml_native(source)
|
34
|
+
source.find_command(
|
35
|
+
'plantuml-full',
|
36
|
+
:raise_on_error => false,
|
37
|
+
:attrs => ['plantuml-native'],
|
38
|
+
:alt_cmds => ['plantuml-headless']
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
30
42
|
def wrap_source(source)
|
31
43
|
PlantUMLPreprocessedSource.new(source, self)
|
32
44
|
end
|
@@ -45,6 +57,8 @@ module Asciidoctor
|
|
45
57
|
theme = source.attr('theme', nil)
|
46
58
|
options[:theme] = theme if theme
|
47
59
|
|
60
|
+
options[:debug] = true if source.opt('debug')
|
61
|
+
|
48
62
|
options
|
49
63
|
end
|
50
64
|
|
@@ -52,6 +66,19 @@ module Asciidoctor
|
|
52
66
|
source.attr('preprocess', 'true') == 'true'
|
53
67
|
end
|
54
68
|
|
69
|
+
def convert(source, format, options)
|
70
|
+
plantuml_native = PlantUmlConverter.find_plantuml_native(source)
|
71
|
+
if plantuml_native
|
72
|
+
convert_native(plantuml_native, source, format, options)
|
73
|
+
elsif PLANTUML_JARS
|
74
|
+
convert_http(source, format, options)
|
75
|
+
else
|
76
|
+
raise "Could not load PlantUML. Either require 'asciidoctor-diagram-plantuml' " \
|
77
|
+
"or specify the location of the PlantUML JAR(s) using the 'DIAGRAM_PLANTUML_CLASSPATH' environment variable. " \
|
78
|
+
"Alternatively a PlantUML binary can be provided (plantuml-native in $PATH)."
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
55
82
|
def add_common_headers(headers, source)
|
56
83
|
base_dir = source.base_dir
|
57
84
|
|
@@ -76,10 +103,7 @@ module Asciidoctor
|
|
76
103
|
headers['X-PlantUML-SizeLimit'] = limit if limit
|
77
104
|
end
|
78
105
|
|
79
|
-
def
|
80
|
-
unless PLANTUML_JARS
|
81
|
-
raise "Could not load PlantUML. Either require 'asciidoctor-diagram-plantuml' or specify the location of the PlantUML JAR(s) using the 'DIAGRAM_PLANTUML_CLASSPATH' environment variable."
|
82
|
-
end
|
106
|
+
def convert_http(source, format, options)
|
83
107
|
Java.load
|
84
108
|
|
85
109
|
code = source.code
|
@@ -98,7 +122,7 @@ module Asciidoctor
|
|
98
122
|
end
|
99
123
|
|
100
124
|
headers = {
|
101
|
-
|
125
|
+
'Accept' => mime_type
|
102
126
|
}
|
103
127
|
|
104
128
|
unless should_preprocess(source)
|
@@ -108,26 +132,129 @@ module Asciidoctor
|
|
108
132
|
add_theme_header(headers, options[:theme])
|
109
133
|
add_size_limit_header(headers, options[:size_limit])
|
110
134
|
|
111
|
-
|
135
|
+
dot = source.find_command('dot', :alt_attrs => ['graphvizdot'], :raise_on_error => false)
|
136
|
+
if options[:smetana] || !dot
|
112
137
|
headers['X-Graphviz'] = 'smetana'
|
113
138
|
else
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
139
|
+
headers['X-Graphviz'] = ::Asciidoctor::Diagram::Platform.host_os_path(dot)
|
140
|
+
end
|
141
|
+
|
142
|
+
if options[:debug]
|
143
|
+
headers['X-PlantUML-Debug'] = 'true'
|
118
144
|
end
|
119
145
|
|
120
146
|
response = Java.send_request(
|
121
|
-
|
122
|
-
|
123
|
-
|
147
|
+
:url => '/plantuml',
|
148
|
+
:body => code,
|
149
|
+
:headers => headers
|
124
150
|
)
|
125
151
|
|
126
152
|
unless response[:code] == 200
|
127
153
|
raise Java.create_error("PlantUML image generation failed", response)
|
128
154
|
end
|
129
155
|
|
130
|
-
response[:
|
156
|
+
if response[:headers]['content-type'] =~ /multipart\/form-data;\s*boundary=(.*)/
|
157
|
+
boundary = $1
|
158
|
+
parts = {}
|
159
|
+
|
160
|
+
multipart_data = StringIO.new(response[:body])
|
161
|
+
while true
|
162
|
+
multipart_data.readline
|
163
|
+
marker = multipart_data.readline
|
164
|
+
if marker.start_with? "--#{boundary}--"
|
165
|
+
break
|
166
|
+
elsif marker.start_with? "--#{boundary}"
|
167
|
+
part = Java.parse_body(multipart_data)
|
168
|
+
if part[:headers]['content-disposition'] =~ /form-data;\s*name="([^"]*)"/
|
169
|
+
if $1 == 'image'
|
170
|
+
parts[:result] = part[:body]
|
171
|
+
else
|
172
|
+
parts[:extra] ||= {}
|
173
|
+
parts[:extra][$1] = part[:body]
|
174
|
+
end
|
175
|
+
else
|
176
|
+
raise "Unexpected multipart content disposition"
|
177
|
+
end
|
178
|
+
else
|
179
|
+
raise "Unexpected multipart boundary"
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
parts
|
184
|
+
else
|
185
|
+
response[:body]
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def add_theme_arg(args, theme)
|
190
|
+
if theme
|
191
|
+
args << '-theme' << theme
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def add_common_args(args, source)
|
196
|
+
base_dir = File.expand_path(source.base_dir)
|
197
|
+
args << '-filedir'
|
198
|
+
args << base_dir
|
199
|
+
|
200
|
+
config_file = source.attr('plantumlconfig', nil, true) || source.attr('config')
|
201
|
+
if config_file
|
202
|
+
args << '-config'
|
203
|
+
args << File.expand_path(config_file, base_dir)
|
204
|
+
end
|
205
|
+
|
206
|
+
include_dir = source.attr('includedir')
|
207
|
+
if include_dir
|
208
|
+
args << "-Dplantuml.include.path=#{Platform.native_path(File.expand_path(include_dir, base_dir))}"
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def convert_native(plantuml, source, format, options)
|
213
|
+
code = source.code
|
214
|
+
|
215
|
+
args = []
|
216
|
+
env = {}
|
217
|
+
|
218
|
+
args << case format
|
219
|
+
when :png
|
220
|
+
'-tpng'
|
221
|
+
when :svg
|
222
|
+
'-tsvg'
|
223
|
+
when :txt, :utxt
|
224
|
+
'-tutxt'
|
225
|
+
when :atxt
|
226
|
+
'-ttxt'
|
227
|
+
else
|
228
|
+
raise "Unsupported format: #{format}"
|
229
|
+
end
|
230
|
+
|
231
|
+
add_common_args(args, source)
|
232
|
+
add_theme_arg(args, options[:theme])
|
233
|
+
|
234
|
+
if options[:size_limit]
|
235
|
+
env['PLANTUML_LIMIT_SIZE'] = options[:size_limit]
|
236
|
+
end
|
237
|
+
|
238
|
+
dot = source.find_command('dot', :alt_attrs => ['graphvizdot'], :raise_on_error => false)
|
239
|
+
if options[:smetana] || !dot
|
240
|
+
args << '-Playout=smetana'
|
241
|
+
else
|
242
|
+
args << '-graphvizdot'
|
243
|
+
args << ::Asciidoctor::Diagram::Platform.host_os_path(dot)
|
244
|
+
end
|
245
|
+
|
246
|
+
generate_stdin_stdout(plantuml, code) do |tool, _|
|
247
|
+
cmd = [tool]
|
248
|
+
cmd << '-pipe'
|
249
|
+
cmd << '-failfast2'
|
250
|
+
cmd << '-stdrpt:1'
|
251
|
+
cmd.concat args
|
252
|
+
|
253
|
+
{
|
254
|
+
:args => cmd,
|
255
|
+
:env => env
|
256
|
+
}
|
257
|
+
end
|
131
258
|
end
|
132
259
|
end
|
133
260
|
|
@@ -144,6 +271,8 @@ module Asciidoctor
|
|
144
271
|
end
|
145
272
|
|
146
273
|
class PlantUMLPreprocessedSource < SimpleDelegator
|
274
|
+
include CliGenerator
|
275
|
+
|
147
276
|
def initialize(source, converter)
|
148
277
|
super(source)
|
149
278
|
@converter = converter
|
@@ -154,34 +283,82 @@ module Asciidoctor
|
|
154
283
|
end
|
155
284
|
|
156
285
|
def load_code
|
157
|
-
Java.load
|
158
|
-
|
159
286
|
code = __getobj__.code
|
160
287
|
|
161
288
|
tag = @converter.class.tag
|
162
289
|
code = "@start#{tag}\n#{code}\n@end#{tag}" unless code.index("@start") && code.index("@end")
|
163
290
|
|
164
291
|
if @converter.should_preprocess(self)
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
:url => '/plantumlpreprocessor',
|
171
|
-
:body => code,
|
172
|
-
:headers => headers
|
173
|
-
)
|
174
|
-
|
175
|
-
unless response[:code] == 200
|
176
|
-
raise Java.create_error("PlantUML preprocessing failed", response)
|
292
|
+
plantuml_native = PlantUmlConverter.find_plantuml_native(self)
|
293
|
+
if plantuml_native
|
294
|
+
code = preprocess_native(plantuml_native, code)
|
295
|
+
else
|
296
|
+
code = preprocess_http(code)
|
177
297
|
end
|
178
|
-
|
179
|
-
code = response[:body]
|
180
|
-
code.force_encoding(Encoding::UTF_8)
|
181
298
|
end
|
182
299
|
|
183
300
|
code
|
184
301
|
end
|
302
|
+
|
303
|
+
private
|
304
|
+
|
305
|
+
def preprocess_http(code)
|
306
|
+
Java.load
|
307
|
+
|
308
|
+
headers = {}
|
309
|
+
@converter.add_common_headers(headers, self)
|
310
|
+
@converter.add_theme_header(headers, @converter.collect_options(self)[:theme])
|
311
|
+
|
312
|
+
response = Java.send_request(
|
313
|
+
:url => '/plantumlpreprocessor',
|
314
|
+
:body => code,
|
315
|
+
:headers => headers
|
316
|
+
)
|
317
|
+
|
318
|
+
unless response[:code] == 200
|
319
|
+
raise Java.create_error("PlantUML preprocessing failed", response)
|
320
|
+
end
|
321
|
+
|
322
|
+
code = response[:body]
|
323
|
+
code.force_encoding(Encoding::UTF_8)
|
324
|
+
end
|
325
|
+
|
326
|
+
def preprocess_native(plantuml, code)
|
327
|
+
generate_stdin_stdout(plantuml, code) do |tool, _|
|
328
|
+
cmd = [tool]
|
329
|
+
cmd << '-pipe'
|
330
|
+
cmd << '-preproc'
|
331
|
+
cmd << '-failfast2'
|
332
|
+
cmd << '-stdrpt:1'
|
333
|
+
|
334
|
+
@converter.add_common_args(cmd, self)
|
335
|
+
@converter.add_theme_arg(cmd, @converter.collect_options(self)[:theme])
|
336
|
+
|
337
|
+
base_dir = File.expand_path(self.base_dir)
|
338
|
+
cmd << '-filedir'
|
339
|
+
cmd << base_dir
|
340
|
+
|
341
|
+
config_file = self.attr('plantumlconfig', nil, true) || self.attr('config')
|
342
|
+
if config_file
|
343
|
+
cmd << '-config'
|
344
|
+
cmd << File.expand_path(config_file, base_dir)
|
345
|
+
end
|
346
|
+
|
347
|
+
include_dir = self.attr('includedir')
|
348
|
+
if include_dir
|
349
|
+
cmd << "-Dplantuml.include.path=#{Platform.native_path(File.expand_path(include_dir, base_dir))}"
|
350
|
+
end
|
351
|
+
|
352
|
+
theme = @converter.collect_options(self)[:theme]
|
353
|
+
if theme
|
354
|
+
cmd << '-theme' << theme
|
355
|
+
end
|
356
|
+
|
357
|
+
{
|
358
|
+
:args => cmd
|
359
|
+
}
|
360
|
+
end
|
361
|
+
end
|
185
362
|
end
|
186
363
|
end
|
187
364
|
end
|
Binary file
|
Binary file
|
@@ -58,25 +58,34 @@ module Asciidoctor
|
|
58
58
|
resp[:code] = status_line_parts[1].to_i
|
59
59
|
resp[:reason] = status_line_parts[2]
|
60
60
|
|
61
|
+
resp.merge! parse_body(io)
|
62
|
+
|
63
|
+
resp
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.parse_body(io)
|
67
|
+
body = {}
|
68
|
+
|
69
|
+
io.set_encoding Encoding::US_ASCII
|
61
70
|
headers = {}
|
62
71
|
until (header = io.readline(CRLF).strip).empty?
|
63
72
|
key, value = header.split ':', 2
|
64
|
-
headers[key] = value.strip
|
73
|
+
headers[key.downcase] = value.strip
|
65
74
|
end
|
66
75
|
|
67
|
-
|
76
|
+
body[:headers] = headers
|
68
77
|
|
69
|
-
content_length = headers['
|
78
|
+
content_length = headers['content-length']
|
70
79
|
if content_length
|
71
80
|
io.set_encoding Encoding::BINARY
|
72
|
-
|
81
|
+
body[:body] = io.read(content_length.to_i)
|
73
82
|
end
|
74
83
|
|
75
|
-
|
84
|
+
body
|
76
85
|
end
|
77
86
|
|
78
87
|
def self.create_error(prefix_msg, response)
|
79
|
-
content_type = response[:headers]['
|
88
|
+
content_type = response[:headers]['content-type'] || 'text/plain'
|
80
89
|
if content_type.start_with? 'application/json'
|
81
90
|
json = JSON.parse(response[:body].force_encoding(Encoding::UTF_8))
|
82
91
|
ruby_bt = Kernel.caller(2)
|
@@ -97,7 +106,6 @@ module Asciidoctor
|
|
97
106
|
@java_exe
|
98
107
|
end
|
99
108
|
|
100
|
-
private
|
101
109
|
def self.find_java
|
102
110
|
case ::Asciidoctor::Diagram::Platform.os
|
103
111
|
when :windows
|
@@ -18,6 +18,16 @@ module Asciidoctor
|
|
18
18
|
raise "Classpath item #{j} does not exist" unless File.exist?(j)
|
19
19
|
require j
|
20
20
|
end
|
21
|
+
|
22
|
+
# Strange issue seen with JRuby where 'java.class.path' has the value ':'.
|
23
|
+
# This causes issue in PlantUML which splits the class path string and then
|
24
|
+
# raises errors when trying to handle empty strings.
|
25
|
+
java_cp = ::Java.java.lang.System.getProperty("java.class.path")
|
26
|
+
new_java_cp = java_cp.split(File::PATH_SEPARATOR)
|
27
|
+
.reject { |p| p.empty? }
|
28
|
+
.join "File::PATH_SEPARATOR"
|
29
|
+
::Java.java.lang.System.setProperty("java.class.path", new_java_cp)
|
30
|
+
|
21
31
|
@loaded = true
|
22
32
|
end
|
23
33
|
|
Binary file
|
data/lib/asciidoctor-diagram.rb
CHANGED
@@ -19,6 +19,7 @@ require_relative 'asciidoctor-diagram/msc'
|
|
19
19
|
require_relative 'asciidoctor-diagram/nomnoml'
|
20
20
|
require_relative 'asciidoctor-diagram/penrose'
|
21
21
|
require_relative 'asciidoctor-diagram/pikchr'
|
22
|
+
require_relative 'asciidoctor-diagram/pintora'
|
22
23
|
require_relative 'asciidoctor-diagram/plantuml'
|
23
24
|
require_relative 'asciidoctor-diagram/salt'
|
24
25
|
require_relative 'asciidoctor-diagram/shaape'
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-diagram
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pepijn Van Eeckhoudt
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-04-24 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -72,34 +71,6 @@ dependencies:
|
|
72
71
|
- - "<"
|
73
72
|
- !ruby/object:Gem::Version
|
74
73
|
version: 3.x
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: asciidoctor-diagram-ditaamini
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '1.0'
|
82
|
-
type: :runtime
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - "~>"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '1.0'
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: asciidoctor-diagram-plantuml
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - "~>"
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '1.2021'
|
96
|
-
type: :runtime
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - "~>"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '1.2021'
|
103
74
|
- !ruby/object:Gem::Dependency
|
104
75
|
name: rexml
|
105
76
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,10 +167,13 @@ files:
|
|
196
167
|
- lib/asciidoctor-diagram/pikchr.rb
|
197
168
|
- lib/asciidoctor-diagram/pikchr/converter.rb
|
198
169
|
- lib/asciidoctor-diagram/pikchr/extension.rb
|
170
|
+
- lib/asciidoctor-diagram/pintora.rb
|
171
|
+
- lib/asciidoctor-diagram/pintora/converter.rb
|
172
|
+
- lib/asciidoctor-diagram/pintora/extension.rb
|
199
173
|
- lib/asciidoctor-diagram/plantuml.rb
|
200
174
|
- lib/asciidoctor-diagram/plantuml/converter.rb
|
201
175
|
- lib/asciidoctor-diagram/plantuml/extension.rb
|
202
|
-
- lib/asciidoctor-diagram/plantuml/plantuml-2.2.
|
176
|
+
- lib/asciidoctor-diagram/plantuml/plantuml-2.2.4.jar
|
203
177
|
- lib/asciidoctor-diagram/salt.rb
|
204
178
|
- lib/asciidoctor-diagram/shaape.rb
|
205
179
|
- lib/asciidoctor-diagram/shaape/converter.rb
|
@@ -211,7 +185,7 @@ files:
|
|
211
185
|
- lib/asciidoctor-diagram/structurizr/converter.rb
|
212
186
|
- lib/asciidoctor-diagram/structurizr/extension.rb
|
213
187
|
- lib/asciidoctor-diagram/structurizr/renderers.rb
|
214
|
-
- lib/asciidoctor-diagram/structurizr/structurizr-2.2.
|
188
|
+
- lib/asciidoctor-diagram/structurizr/structurizr-2.2.2.jar
|
215
189
|
- lib/asciidoctor-diagram/svgbob.rb
|
216
190
|
- lib/asciidoctor-diagram/svgbob/converter.rb
|
217
191
|
- lib/asciidoctor-diagram/svgbob/extension.rb
|
@@ -239,7 +213,7 @@ files:
|
|
239
213
|
- lib/asciidoctor-diagram/util/pdf.rb
|
240
214
|
- lib/asciidoctor-diagram/util/platform.rb
|
241
215
|
- lib/asciidoctor-diagram/util/png.rb
|
242
|
-
- lib/asciidoctor-diagram/util/server-2.2.
|
216
|
+
- lib/asciidoctor-diagram/util/server-2.2.3.jar
|
243
217
|
- lib/asciidoctor-diagram/util/svg.rb
|
244
218
|
- lib/asciidoctor-diagram/util/which.rb
|
245
219
|
- lib/asciidoctor-diagram/vega.rb
|
@@ -258,7 +232,6 @@ metadata:
|
|
258
232
|
documentation_uri: https://docs.asciidoctor.org/diagram-extension/latest/
|
259
233
|
homepage_uri: https://github.com/asciidoctor/asciidoctor-diagram
|
260
234
|
source_code_uri: https://github.com/asciidoctor/asciidoctor-diagram.git
|
261
|
-
post_install_message:
|
262
235
|
rdoc_options: []
|
263
236
|
require_paths:
|
264
237
|
- lib
|
@@ -273,8 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
246
|
- !ruby/object:Gem::Version
|
274
247
|
version: '0'
|
275
248
|
requirements: []
|
276
|
-
rubygems_version: 3.
|
277
|
-
signing_key:
|
249
|
+
rubygems_version: 3.6.3
|
278
250
|
specification_version: 4
|
279
251
|
summary: A family of Asciidoctor extensions that generate images from a broad range
|
280
252
|
of embedded plain text diagram descriptions, including PlantUML, ditaa, Kroki, and
|
Binary file
|
Binary file
|