22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/asciidoctor-diagram/mermaid/extension.rb', line 22
def mermaid(parent, source, format)
mermaid = which(parent, 'mermaid')
@is_mermaid_v6 ||= ::Asciidoctor::Diagram::Cli.run(mermaid, '--version').split('.')[0].to_i >= 6
phantomjs = which(parent, 'phantomjs', :alt_attrs => [@is_mermaid_v6 ? 'phantomjs_2' : 'phantomjs_19'])
seq_config = source.attr('sequenceConfig', nil, true)
if seq_config
seq_config = parent.normalize_system_path(seq_config, source.base_dir)
end
width = source.attr('width')
generate_file(mermaid, 'mmd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
output_dir = File.dirname(output_path)
output_file = File.expand_path(File.basename(input_path) + ".#{format.to_s}", output_dir)
args = [tool_path, '--phantomPath', Platform.native_path(phantomjs), "--#{format.to_s}", '-o', Platform.native_path(output_dir)]
if seq_config
args << '--sequenceConfig' << Platform.native_path(seq_config)
end
if width
args << '--width' << width
end
args << Platform.native_path(input_path)
{
:args => args,
:out_file => output_file
}
end
end
|