Class: Asciidoctor::Diagram::D2Converter
Instance Method Summary
collapse
#generate_file, #generate_file_stdout, #generate_stdin, #generate_stdin_file, #generate_stdin_stdout
#native_scaling?, #wrap_source
Instance Method Details
#collect_options(source) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/asciidoctor-diagram/d2/converter.rb', line 16
def collect_options(source)
{
:layout => source.attr('layout'),
:theme => source.attr('theme'),
:pad => source.attr('pad'),
:animate_interval => source.attr('animate-interval'),
:sketch => source.attr('sketch'),
:font_regular => source.attr('font-regular'),
:font_italic => source.attr('font-italic'),
:font_bold => source.attr('font-bold')
}
end
|
#convert(source, format, options) ⇒ Object
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
|
# File 'lib/asciidoctor-diagram/d2/converter.rb', line 29
def convert(source, format, options)
generate_stdin(source.find_command('d2'), format.to_s, source.code) do |tool_path, output_path|
args = [tool_path, '--browser', 'false']
options.each_pair do |key, value|
flag = "--#{key.to_s.gsub('_', '-')}"
if key == :sketch && !value.nil? && value != 'false'
args << flag
elsif key.to_s.start_with?('font') && !value.nil?
args << Platform.native_path(value)
elsif !value.nil?
args << flag
args << value
end
end
args << '-'
args << Platform.native_path(output_path)
{
:args => args,
:chdir => source.base_dir
}
end
end
|
12
13
14
|
# File 'lib/asciidoctor-diagram/d2/converter.rb', line 12
def supported_formats
[:svg, :png, :pdf]
end
|