asciidoctor-diagram 2.2.3 → 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 +159 -0
- data/README.adoc +17 -13
- data/lib/asciidoctor-diagram/a2s/converter.rb +7 -2
- data/lib/asciidoctor-diagram/barcode/converter.rb +83 -78
- data/lib/asciidoctor-diagram/blockdiag/converter.rb +12 -2
- data/lib/asciidoctor-diagram/bpmn/converter.rb +4 -1
- data/lib/asciidoctor-diagram/bytefield/converter.rb +4 -1
- data/lib/asciidoctor-diagram/d2/converter.rb +57 -0
- data/lib/asciidoctor-diagram/d2/extension.rb +18 -0
- data/lib/asciidoctor-diagram/d2.rb +8 -0
- data/lib/asciidoctor-diagram/dbml/converter.rb +27 -0
- data/lib/asciidoctor-diagram/dbml/extension.rb +18 -0
- data/lib/asciidoctor-diagram/dbml.rb +8 -0
- data/lib/asciidoctor-diagram/diagram_processor.rb +49 -9
- data/lib/asciidoctor-diagram/diagram_source.rb +35 -33
- data/lib/asciidoctor-diagram/diagrams/converter.rb +4 -1
- data/lib/asciidoctor-diagram/ditaa/converter.rb +15 -7
- data/lib/asciidoctor-diagram/ditaa/ditaa-2.2.0.jar +0 -0
- data/lib/asciidoctor-diagram/dpic/converter.rb +4 -1
- data/lib/asciidoctor-diagram/erd/converter.rb +5 -2
- data/lib/asciidoctor-diagram/gnuplot/converter.rb +7 -1
- data/lib/asciidoctor-diagram/graphviz/converter.rb +4 -1
- data/lib/asciidoctor-diagram/graphviz_py/converter.rb +4 -1
- data/lib/asciidoctor-diagram/http/converter.rb +16 -7
- data/lib/asciidoctor-diagram/http/server.rb +2 -2
- data/lib/asciidoctor-diagram/lilypond/converter.rb +3 -2
- data/lib/asciidoctor-diagram/meme/converter.rb +29 -3
- data/lib/asciidoctor-diagram/mermaid/converter.rb +4 -2
- data/lib/asciidoctor-diagram/msc/converter.rb +6 -2
- data/lib/asciidoctor-diagram/nomnoml/converter.rb +4 -1
- data/lib/asciidoctor-diagram/penrose/converter.rb +53 -0
- data/lib/asciidoctor-diagram/penrose/extension.rb +18 -0
- data/lib/asciidoctor-diagram/penrose.rb +8 -0
- data/lib/asciidoctor-diagram/pikchr/converter.rb +4 -1
- 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 +256 -43
- data/lib/asciidoctor-diagram/plantuml/plantuml-2.2.4.jar +0 -0
- data/lib/asciidoctor-diagram/shaape/converter.rb +4 -1
- data/lib/asciidoctor-diagram/smcat/converter.rb +5 -1
- data/lib/asciidoctor-diagram/structurizr/converter.rb +69 -0
- data/lib/asciidoctor-diagram/structurizr/extension.rb +52 -0
- data/lib/asciidoctor-diagram/structurizr/renderers.rb +63 -0
- data/lib/asciidoctor-diagram/structurizr/structurizr-2.2.2.jar +0 -0
- data/lib/asciidoctor-diagram/structurizr.rb +7 -0
- data/lib/asciidoctor-diagram/svgbob/converter.rb +6 -2
- data/lib/asciidoctor-diagram/symbolator/converter.rb +4 -1
- data/lib/asciidoctor-diagram/syntrax/converter.rb +72 -17
- data/lib/asciidoctor-diagram/syntrax/syntrax-2.2.0.jar +0 -0
- data/lib/asciidoctor-diagram/tikz/converter.rb +5 -2
- data/lib/asciidoctor-diagram/umlet/converter.rb +4 -1
- data/lib/asciidoctor-diagram/util/base64.rb +25 -0
- data/lib/asciidoctor-diagram/util/cli.rb +11 -3
- data/lib/asciidoctor-diagram/util/cli_generator.rb +1 -0
- data/lib/asciidoctor-diagram/util/java.rb +15 -7
- data/lib/asciidoctor-diagram/util/java_jruby.rb +14 -0
- data/lib/asciidoctor-diagram/util/java_socket.rb +4 -0
- data/lib/asciidoctor-diagram/util/server-2.2.3.jar +0 -0
- data/lib/asciidoctor-diagram/util/svg.rb +5 -3
- data/lib/asciidoctor-diagram/vega/converter.rb +5 -3
- data/lib/asciidoctor-diagram/version.rb +1 -1
- data/lib/asciidoctor-diagram/wavedrom/converter.rb +38 -24
- data/lib/asciidoctor-diagram.rb +5 -0
- metadata +32 -115
- data/Rakefile +0 -9
- data/docs/antora.yml +0 -3
- data/docs/modules/ROOT/images/asciidoctor-diagram-classes.png +0 -0
- data/docs/modules/ROOT/images/asciidoctor-diagram-process.png +0 -0
- data/docs/modules/ROOT/pages/index.adoc +0 -21
- data/docs/modules/ROOT/partials/advanced.adoc +0 -365
- data/docs/modules/ROOT/partials/create_diagram.adoc +0 -134
- data/docs/modules/ROOT/partials/generate.adoc +0 -15
- data/docs/modules/ROOT/partials/installation.adoc +0 -19
- data/docs/modules/ROOT/partials/uris.adoc +0 -41
- data/examples/Gemfile +0 -3
- data/examples/README.adoc +0 -18
- data/examples/design.adoc +0 -78
- data/examples/features.adoc +0 -189
- data/lib/asciidoctor-diagram/ditaa/ditaa-1.3.21.jar +0 -0
- data/lib/asciidoctor-diagram/plantuml/plantuml-1.3.21.jar +0 -0
- data/lib/asciidoctor-diagram/util/server-1.3.21.jar +0 -0
- data/spec/a2s_spec.rb +0 -33
- data/spec/barcode_spec.rb +0 -176
- data/spec/blockdiag_spec.rb +0 -20
- data/spec/bpmn_spec.rb +0 -60
- data/spec/bytefield_spec.rb +0 -96
- data/spec/diagrams_spec.rb +0 -27
- data/spec/ditaa_spec.rb +0 -191
- data/spec/dpic_spec.rb +0 -23
- data/spec/erd_spec.rb +0 -96
- data/spec/gnuplot_spec.rb +0 -229
- data/spec/graphviz_py_spec.rb +0 -33
- data/spec/graphviz_spec.rb +0 -24
- data/spec/lilypond_spec.rb +0 -17
- data/spec/man.jpg +0 -0
- data/spec/meme_spec.rb +0 -67
- data/spec/mermaid_spec.rb +0 -198
- data/spec/msc_spec.rb +0 -37
- data/spec/nomnoml_spec.rb +0 -36
- data/spec/pikchr_spec.rb +0 -73
- data/spec/plantuml_spec.rb +0 -772
- data/spec/shaape_spec.rb +0 -20
- data/spec/shared_examples.rb +0 -764
- data/spec/smcat_spec.rb +0 -30
- data/spec/svgbob_spec.rb +0 -33
- data/spec/symbolator_spec.rb +0 -27
- data/spec/syntrax_spec.rb +0 -22
- data/spec/test_helper.rb +0 -113
- data/spec/tikz_spec.rb +0 -181
- data/spec/umlet_spec.rb +0 -32
- data/spec/vega_spec.rb +0 -133
- data/spec/wavedrom_spec.rb +0 -21
@@ -0,0 +1,63 @@
|
|
1
|
+
require_relative '../d2/extension'
|
2
|
+
require_relative '../graphviz/extension'
|
3
|
+
require_relative '../mermaid/extension'
|
4
|
+
require_relative '../plantuml/extension'
|
5
|
+
|
6
|
+
module Asciidoctor
|
7
|
+
module Diagram
|
8
|
+
class Renderers
|
9
|
+
D2 = 'd2'
|
10
|
+
GRAPHVIZ = 'graphviz'
|
11
|
+
MERMAID = 'mermaid'
|
12
|
+
PLANTUML_C4 = 'plantuml-c4'
|
13
|
+
PLANTUML = 'plantuml'
|
14
|
+
DEFAULT_RENDERER = PLANTUML_C4
|
15
|
+
|
16
|
+
def initialize(name)
|
17
|
+
@d2 = D2BlockProcessor.new(name)
|
18
|
+
@graphviz = GraphvizBlockProcessor.new(name)
|
19
|
+
@plantuml = PlantUmlBlockProcessor.new(name)
|
20
|
+
@mermaid = MermaidBlockProcessor.new(name)
|
21
|
+
end
|
22
|
+
|
23
|
+
def renderer(renderer_type)
|
24
|
+
case renderer_type
|
25
|
+
when D2
|
26
|
+
@d2
|
27
|
+
when GRAPHVIZ
|
28
|
+
@graphviz
|
29
|
+
when MERMAID
|
30
|
+
@mermaid
|
31
|
+
when PLANTUML, PLANTUML_C4
|
32
|
+
@plantuml
|
33
|
+
else
|
34
|
+
raise "Unsupported renderer: '#{renderer_type}'"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_renderer(source)
|
39
|
+
renderer(Renderers.get_renderer_type(source))
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.get_renderer_type(source)
|
43
|
+
source.attr('renderer', PLANTUML_C4)
|
44
|
+
end
|
45
|
+
def self.mime_type(renderer_type)
|
46
|
+
case renderer_type
|
47
|
+
when D2
|
48
|
+
'text/x-d2'
|
49
|
+
when GRAPHVIZ
|
50
|
+
'text/vnd.graphviz'
|
51
|
+
when MERMAID
|
52
|
+
'text/x-mermaid'
|
53
|
+
when PLANTUML
|
54
|
+
'text/x-plantuml'
|
55
|
+
when PLANTUML_C4
|
56
|
+
'text/x-plantuml-c4'
|
57
|
+
else
|
58
|
+
raise "Unsupported renderer: '#{renderer_type}'"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
Binary file
|
@@ -0,0 +1,7 @@
|
|
1
|
+
require 'asciidoctor/extensions'
|
2
|
+
require_relative 'structurizr/extension'
|
3
|
+
|
4
|
+
Asciidoctor::Extensions.register do
|
5
|
+
block Asciidoctor::Diagram::StructurizrBlockProcessor, :structurizr
|
6
|
+
block_macro Asciidoctor::Diagram::StructurizrBlockMacroProcessor, :structurizr
|
7
|
+
end
|
@@ -11,7 +11,7 @@ module Asciidoctor
|
|
11
11
|
|
12
12
|
|
13
13
|
def supported_formats
|
14
|
-
[:svg]
|
14
|
+
[:svg, :txt]
|
15
15
|
end
|
16
16
|
|
17
17
|
def native_scaling?
|
@@ -38,6 +38,7 @@ module Asciidoctor
|
|
38
38
|
|
39
39
|
|
40
40
|
def convert(source, format, options)
|
41
|
+
return source.to_s if format == :txt
|
41
42
|
|
42
43
|
flags = []
|
43
44
|
options.each do |option, value|
|
@@ -45,7 +46,10 @@ module Asciidoctor
|
|
45
46
|
end
|
46
47
|
|
47
48
|
generate_stdin(source.find_command('svgbob', :alt_cmds => ['svgbob_cli']), format.to_s, source.to_s) do |tool_path, output_path|
|
48
|
-
|
49
|
+
{
|
50
|
+
:args => ([tool_path, '-o', Platform.native_path(output_path)] + flags),
|
51
|
+
:chdir => source.base_dir
|
52
|
+
}
|
49
53
|
end
|
50
54
|
end
|
51
55
|
end
|
@@ -15,7 +15,10 @@ module Asciidoctor
|
|
15
15
|
|
16
16
|
def convert(source, format, options)
|
17
17
|
generate_stdin(source.find_command('symbolator'), format.to_s, source.to_s) do |tool_path, output_path|
|
18
|
-
|
18
|
+
{
|
19
|
+
:args => [tool_path, "-i-", "-o#{Platform.native_path(output_path)}", "-f#{format.to_s}"],
|
20
|
+
:chdir => source.base_dir
|
21
|
+
}
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
@@ -9,6 +9,26 @@ module Asciidoctor
|
|
9
9
|
include DiagramConverter
|
10
10
|
include CliGenerator
|
11
11
|
|
12
|
+
CLASSPATH_ENV = Java.environment_variable('DIAGRAM_JSYNTRAX_CLASSPATH')
|
13
|
+
CLI_HOME_ENV = Java.environment_variable('DIAGRAM_JSYNTRAX_HOME')
|
14
|
+
JSYNTRAX_JARS = if CLASSPATH_ENV
|
15
|
+
CLASSPATH_ENV.split(File::PATH_SEPARATOR)
|
16
|
+
elsif CLI_HOME_ENV
|
17
|
+
lib_dir = File.expand_path('lib', CLI_HOME_ENV)
|
18
|
+
Dir.children(lib_dir).select { |c| c.end_with? '.jar' }.map { |c| File.expand_path(c, lib_dir) }
|
19
|
+
else
|
20
|
+
begin
|
21
|
+
require 'asciidoctor-diagram/jsyntrax/classpath'
|
22
|
+
::Asciidoctor::Diagram::JsyntraxClasspath::JAR_FILES
|
23
|
+
rescue LoadError
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
if JSYNTRAX_JARS
|
29
|
+
Java.classpath.concat Dir[File.join(File.dirname(__FILE__), '*.jar')]
|
30
|
+
Java.classpath.concat JSYNTRAX_JARS
|
31
|
+
end
|
12
32
|
|
13
33
|
def supported_formats
|
14
34
|
[:png, :svg]
|
@@ -24,30 +44,65 @@ module Asciidoctor
|
|
24
44
|
end
|
25
45
|
|
26
46
|
def convert(source, format, options)
|
27
|
-
|
28
|
-
|
47
|
+
shared_args = []
|
48
|
+
title = options[:heading]
|
49
|
+
if title
|
50
|
+
shared_args << '--title' << title
|
51
|
+
end
|
29
52
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
53
|
+
scale = options[:scale]
|
54
|
+
if scale
|
55
|
+
shared_args << '--scale' << scale
|
56
|
+
end
|
34
57
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
58
|
+
transparent = options[:transparent]
|
59
|
+
if transparent == 'true'
|
60
|
+
shared_args << '--transparent'
|
61
|
+
end
|
62
|
+
style = options[:style]
|
63
|
+
if style
|
64
|
+
shared_args << '--style' << style
|
65
|
+
end
|
39
66
|
|
40
|
-
|
41
|
-
|
42
|
-
|
67
|
+
if JSYNTRAX_JARS
|
68
|
+
Java.load
|
69
|
+
|
70
|
+
options_string = shared_args.join(' ')
|
71
|
+
|
72
|
+
case format
|
73
|
+
when :png
|
74
|
+
mime_type = 'image/png'
|
75
|
+
when :svg
|
76
|
+
mime_type = 'image/svg+xml'
|
77
|
+
else
|
78
|
+
raise "Unsupported format: #{format}"
|
43
79
|
end
|
44
|
-
|
45
|
-
|
46
|
-
|
80
|
+
|
81
|
+
headers = {
|
82
|
+
'Accept' => mime_type,
|
83
|
+
'X-Options' => options_string
|
84
|
+
}
|
85
|
+
|
86
|
+
response = Java.send_request(
|
87
|
+
:url => '/syntrax',
|
88
|
+
:body => source.to_s,
|
89
|
+
:headers => headers
|
90
|
+
)
|
91
|
+
|
92
|
+
unless response[:code] == 200
|
93
|
+
raise Java.create_error("JSyntrax code generation failed", response)
|
47
94
|
end
|
48
95
|
|
49
|
-
|
96
|
+
response[:body]
|
97
|
+
else
|
98
|
+
generate_file(source.find_command('syntrax'), 'spec', format.to_s, source.to_s) do |tool_path, input_path, output_path|
|
99
|
+
{
|
100
|
+
:args => ([tool_path, '-i', Platform.native_path(input_path), '-o', Platform.native_path(output_path)] + shared_args),
|
101
|
+
:chdir => source.base_dir
|
102
|
+
}
|
103
|
+
end
|
50
104
|
end
|
105
|
+
|
51
106
|
end
|
52
107
|
|
53
108
|
def native_scaling?
|
Binary file
|
@@ -15,7 +15,7 @@ module Asciidoctor
|
|
15
15
|
|
16
16
|
def collect_options(source)
|
17
17
|
{
|
18
|
-
:preamble => source.attr('preamble') == 'true'
|
18
|
+
:preamble => source.opt('preamble') || source.attr('preamble') == 'true'
|
19
19
|
}
|
20
20
|
end
|
21
21
|
|
@@ -64,7 +64,10 @@ END
|
|
64
64
|
|
65
65
|
if svgpath
|
66
66
|
generate_file(svgpath, 'pdf', 'svg', pdf) do |tool_path, input_path, output_path|
|
67
|
-
|
67
|
+
{
|
68
|
+
:args => [tool_path, Platform.native_path(input_path), Platform.native_path(output_path)],
|
69
|
+
:chdir => source.base_dir
|
70
|
+
}
|
68
71
|
end
|
69
72
|
else
|
70
73
|
pdf
|
@@ -25,7 +25,10 @@ module Asciidoctor
|
|
25
25
|
end
|
26
26
|
|
27
27
|
generate_file(java, 'uxf', format.to_s, source.to_s) do |tool_path, input_path, output_path|
|
28
|
-
|
28
|
+
{
|
29
|
+
:args => [tool_path, '-jar', Platform.native_path(umlet), '-action=convert', "-format=#{format.to_s}", "-filename=#{Platform.native_path(input_path)}", "-output=#{Platform.native_path(output_path)}"],
|
30
|
+
:chdir => source.base_dir
|
31
|
+
}
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Asciidoctor
|
2
|
+
module Diagram
|
3
|
+
module Base64
|
4
|
+
def self.urlsafe_encode(bin, padding: true)
|
5
|
+
str = [bin].pack("m0")
|
6
|
+
str.chomp!("==") or str.chomp!("=") unless padding
|
7
|
+
str.tr!("+/", "-_")
|
8
|
+
str
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.urlsafe_decode(str)
|
12
|
+
# NOTE: RFC 4648 does say nothing about unpadded input, but says that
|
13
|
+
# "the excess pad characters MAY also be ignored", so it is inferred that
|
14
|
+
# unpadded input is also acceptable.
|
15
|
+
if !str.end_with?("=") && str.length % 4 != 0
|
16
|
+
str = str.ljust((str.length + 3) & ~3, "=")
|
17
|
+
str.tr!("-_", "+/")
|
18
|
+
else
|
19
|
+
str = str.tr("-_", "+/")
|
20
|
+
end
|
21
|
+
str.unpack1("m0")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -9,8 +9,13 @@ module Asciidoctor
|
|
9
9
|
require_relative 'java'
|
10
10
|
|
11
11
|
def self.run(*args)
|
12
|
-
|
13
|
-
|
12
|
+
if args.last.is_a? Hash
|
13
|
+
opts = args.pop.dup
|
14
|
+
else
|
15
|
+
opts = {}
|
16
|
+
end
|
17
|
+
|
18
|
+
in_data = opts[:stdin_data]
|
14
19
|
|
15
20
|
if Hash === args.first
|
16
21
|
env = args.shift.dup
|
@@ -19,6 +24,9 @@ module Asciidoctor
|
|
19
24
|
end
|
20
25
|
|
21
26
|
pb = java.lang.ProcessBuilder.new(*args)
|
27
|
+
|
28
|
+
pb.directory(java.io.File.new(opts[:chdir] || Dir.pwd))
|
29
|
+
|
22
30
|
env.each_pair do |key, value|
|
23
31
|
pb.environment.put(key, value)
|
24
32
|
end
|
@@ -92,7 +100,7 @@ module Asciidoctor
|
|
92
100
|
exit = status.exitstatus
|
93
101
|
|
94
102
|
if exit != 0
|
95
|
-
raise "#{cmd} failed: #{
|
103
|
+
raise "#{cmd} failed: #{stderr.empty? ? stdout : stderr}"
|
96
104
|
end
|
97
105
|
|
98
106
|
{
|
@@ -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
|
@@ -5,6 +5,10 @@ module Asciidoctor
|
|
5
5
|
module Diagram
|
6
6
|
# @private
|
7
7
|
module Java
|
8
|
+
def self.environment_variable(key)
|
9
|
+
ENV[key] || ENV_JAVA[key.downcase.gsub('_', '.')]
|
10
|
+
end
|
11
|
+
|
8
12
|
def self.load
|
9
13
|
if defined?(@loaded) && @loaded
|
10
14
|
return
|
@@ -14,6 +18,16 @@ module Asciidoctor
|
|
14
18
|
raise "Classpath item #{j} does not exist" unless File.exist?(j)
|
15
19
|
require j
|
16
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
|
+
|
17
31
|
@loaded = true
|
18
32
|
end
|
19
33
|
|
Binary file
|
@@ -28,8 +28,10 @@ module Asciidoctor
|
|
28
28
|
|
29
29
|
viewbox = root.attributes['viewBox']
|
30
30
|
if (v = VIEWBOX_REGEX.match(viewbox)) && width.nil? && height.nil?
|
31
|
-
|
32
|
-
|
31
|
+
min_x = to_numeric(v[:min_x])
|
32
|
+
min_y = to_numeric(v[:min_y])
|
33
|
+
width ||= to_numeric(v[:width]) - min_x
|
34
|
+
height ||= to_numeric(v[:height]) - min_y
|
33
35
|
end
|
34
36
|
|
35
37
|
if viewbox.nil? && width && height
|
@@ -76,7 +78,7 @@ module Asciidoctor
|
|
76
78
|
end
|
77
79
|
|
78
80
|
WIDTH_HEIGHT_REGEX = /^\s*(?<value>\d+(?:\.\d+)?)\s*(?<unit>[a-zA-Z]+)?\s*$/
|
79
|
-
VIEWBOX_REGEX = /^\s
|
81
|
+
VIEWBOX_REGEX = /^\s*(?<min_x>-?\d+(?:\.\d+)?)\s*(?<min_y>-?\d+(?:\.\d+)?)\s*(?<width>\d+(?:\.\d+)?)\s*(?<height>\d+(?:\.\d+)?)\s*$/
|
80
82
|
|
81
83
|
def self.to_px_factor(unit)
|
82
84
|
case unit
|
@@ -32,14 +32,16 @@ module Asciidoctor
|
|
32
32
|
vega_code = code
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
generate_stdin_stdout(source.find_command("vg2#{format}"), vega_code) do |tool_path|
|
36
36
|
args = [tool_path, '--base', Platform.native_path(base_dir)]
|
37
37
|
if format == :svg
|
38
38
|
args << '--header'
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
{
|
42
|
+
:args => args,
|
43
|
+
:chdir => source.base_dir
|
44
|
+
}
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
@@ -9,39 +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
|
-
|
20
|
-
if wavedrom_cli
|
21
|
-
generate_file(wavedrom_cli, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
|
22
|
-
[Platform.native_path(tool_path), '--input', Platform.native_path(input_path), "--#{format.to_s}", Platform.native_path(output_path)]
|
23
|
-
end
|
24
|
-
else
|
25
|
-
wavedrom_cli = source.find_command('wavedrom', :raise_on_error => false)
|
26
|
-
phantomjs = source.find_command('phantomjs', :alt_attrs => ['phantomjs_2'], :raise_on_error => false)
|
17
|
+
wavedrom = source.find_command('wavedrom-cli', :attrs => ['wavedrom'], :raise_on_error => false)
|
27
18
|
|
28
|
-
|
29
|
-
|
30
|
-
|
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')
|
31
28
|
end
|
32
29
|
else
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
wavedrom = File.join(wavedrom, 'Contents/MacOS/nwjs')
|
37
|
-
end
|
38
|
-
else
|
39
|
-
wavedrom = source.find_command('WaveDromEditor')
|
40
|
-
end
|
30
|
+
wavedrom = source.find_command('WaveDromEditor', :raise_on_error => false)
|
31
|
+
end
|
32
|
+
end
|
41
33
|
|
42
|
-
|
43
|
-
|
44
|
-
|
34
|
+
unless wavedrom
|
35
|
+
source.find_command('wavedrom-cli', :attrs => ['wavedrom'])
|
36
|
+
end
|
37
|
+
|
38
|
+
if wavedrom.include?('-cli')
|
39
|
+
generate_file(wavedrom, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
|
40
|
+
{
|
41
|
+
:args => [Platform.native_path(tool_path), '--input', Platform.native_path(input_path), "--#{format.to_s}", Platform.native_path(output_path)],
|
42
|
+
:chdir => source.base_dir
|
43
|
+
}
|
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
|
52
|
+
else
|
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
|
+
}
|
45
59
|
end
|
46
60
|
end
|
47
61
|
end
|
data/lib/asciidoctor-diagram.rb
CHANGED
@@ -3,6 +3,8 @@ require_relative 'asciidoctor-diagram/barcode'
|
|
3
3
|
require_relative 'asciidoctor-diagram/blockdiag'
|
4
4
|
require_relative 'asciidoctor-diagram/bpmn'
|
5
5
|
require_relative 'asciidoctor-diagram/bytefield'
|
6
|
+
require_relative 'asciidoctor-diagram/d2'
|
7
|
+
require_relative 'asciidoctor-diagram/dbml'
|
6
8
|
require_relative 'asciidoctor-diagram/diagrams'
|
7
9
|
require_relative 'asciidoctor-diagram/ditaa'
|
8
10
|
require_relative 'asciidoctor-diagram/dpic'
|
@@ -15,11 +17,14 @@ require_relative 'asciidoctor-diagram/meme'
|
|
15
17
|
require_relative 'asciidoctor-diagram/mermaid'
|
16
18
|
require_relative 'asciidoctor-diagram/msc'
|
17
19
|
require_relative 'asciidoctor-diagram/nomnoml'
|
20
|
+
require_relative 'asciidoctor-diagram/penrose'
|
18
21
|
require_relative 'asciidoctor-diagram/pikchr'
|
22
|
+
require_relative 'asciidoctor-diagram/pintora'
|
19
23
|
require_relative 'asciidoctor-diagram/plantuml'
|
20
24
|
require_relative 'asciidoctor-diagram/salt'
|
21
25
|
require_relative 'asciidoctor-diagram/shaape'
|
22
26
|
require_relative 'asciidoctor-diagram/smcat'
|
27
|
+
require_relative 'asciidoctor-diagram/structurizr'
|
23
28
|
require_relative 'asciidoctor-diagram/svgbob'
|
24
29
|
require_relative 'asciidoctor-diagram/symbolator'
|
25
30
|
require_relative 'asciidoctor-diagram/syntrax'
|